From d722b7621db244280924097c39e2c9813fcbe241 Mon Sep 17 00:00:00 2001 From: Weijie Guo Date: Fri, 22 Nov 2024 15:16:53 +0800 Subject: [PATCH] [CELEBORN-1726][FOLLOWUP] Avoid NPE when transition worker state ### What changes were proposed in this pull request? Avoid NPE when transition worker state ### Why are the changes needed? Fix test. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? No need. Closes #2938 from reswqa/fix-npe. Authored-by: Weijie Guo Signed-off-by: SteNicholas --- .../celeborn/service/deploy/worker/WorkerStatusManager.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/WorkerStatusManager.scala b/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/WorkerStatusManager.scala index 1957cbfce0..e31fcf576a 100644 --- a/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/WorkerStatusManager.scala +++ b/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/WorkerStatusManager.scala @@ -129,7 +129,9 @@ private[celeborn] class WorkerStatusManager(conf: CelebornConf) extends Logging if (allowStates != null && allowStates.contains(state)) { logInfo(s"Worker transition status from ${currentWorkerStatus.getState} to $state.") currentWorkerStatus = new WorkerStatus(state.getNumber, System.currentTimeMillis()) - worker.workerInfo.setWorkerStatus(currentWorkerStatus) + if (worker != null && worker.workerInfo != null) { + worker.workerInfo.setWorkerStatus(currentWorkerStatus) + } } else { logWarning( s"Worker transition status from ${currentWorkerStatus.getState} to $state is not allowed.")