Skip to content

Commit c0963e1

Browse files
committed
[KYUUBI #2510] Fix NPE when invoking YarnApplicationOperation::getApplicationInfoByTag
### _Why are the changes needed?_ null value might be returned for YarnApplicationOperation::getApplicationInfoByTag I met NPE issue yesterday. <img width="1061" alt="image" src="https://user-images.githubusercontent.com/6757692/165871836-ad1e4290-34ee-4941-9463-6cc4384f502e.png"> <img width="1329" alt="image" src="https://user-images.githubusercontent.com/6757692/165871885-3b216dda-ab4f-4663-966d-15c0be5f110f.png"> Here the state might be null, because Some(null) is nonEmpty. ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #2510 from turboFei/batch_npe. Closes #2510 32cad24 [Fei Wang] refactor f0e5f11 [Fei Wang] fix current ut f037d44 [Fei Wang] fix npe when getting ApplicationInfo Authored-by: Fei Wang <fwang12@ebay.com> Signed-off-by: Fei Wang <fwang12@ebay.com>
1 parent beb132f commit c0963e1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KyuubiApplicationManager.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ class KyuubiApplicationManager extends AbstractService("KyuubiApplicationManager
7878
def getApplicationInfo(
7979
clusterManager: Option[String],
8080
tag: String): Option[Map[String, String]] = {
81-
operations.find(_.isSupported(clusterManager)).map(_.getApplicationInfoByTag(tag))
81+
val operation = operations.find(_.isSupported(clusterManager))
82+
operation match {
83+
case Some(op) => Option(op.getApplicationInfoByTag(tag))
84+
case None => None
85+
}
8286
}
8387
}
8488

kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiBatchYarnClusterSuite.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ class KyuubiBatchYarnClusterSuite extends WithKyuubiServerOnYarn {
8080
val appInfo = yarnOperation.getApplicationInfoByTag(sessionHandle.identifier.toString)
8181

8282
assert(appInfo("state") === "KILLED")
83-
assert(batchJobSubmissionOp.getStatus.state === ERROR)
83+
84+
eventually(timeout(10.seconds), interval(50.milliseconds)) {
85+
assert(batchJobSubmissionOp.getStatus.state === ERROR)
86+
}
8487

8588
val resultColumns = batchJobSubmissionOp.getNextRowSet(FetchOrientation.FETCH_NEXT, 10)
8689
.getColumns.asScala

0 commit comments

Comments
 (0)