fix: replace null checks with Option in coordinator
Build & Test (NowChessSystems) TeamCity build failed
Build & Test (NowChessSystems) TeamCity build failed
Use Option instead of null checks in HealthMonitor and InstanceRegistry per Scalafix DisableSyntax rule. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
+3
-2
@@ -139,9 +139,10 @@ class HealthMonitor:
|
|||||||
case _ => ()
|
case _ => ()
|
||||||
|
|
||||||
override def onClose(cause: WatcherException): Unit =
|
override def onClose(cause: WatcherException): Unit =
|
||||||
if cause != null then
|
Option(cause).foreach { ex =>
|
||||||
log.warnf(cause, "Pod watch closed, restarting")
|
log.warnf(ex, "Pod watch closed, restarting")
|
||||||
startPodWatch()
|
startPodWatch()
|
||||||
|
}
|
||||||
)
|
)
|
||||||
log.info("Pod watch started")
|
log.info("Pod watch started")
|
||||||
catch
|
catch
|
||||||
|
|||||||
+3
-2
@@ -51,14 +51,15 @@ class InstanceRegistry:
|
|||||||
keys.asScala.foreach { key =>
|
keys.asScala.foreach { key =>
|
||||||
val instanceId = key.stripPrefix(s"$redisPrefix:instances:")
|
val instanceId = key.stripPrefix(s"$redisPrefix:instances:")
|
||||||
val json = syncRedis.value(classOf[String]).get(key)
|
val json = syncRedis.value(classOf[String]).get(key)
|
||||||
if json != null then
|
Option(json).foreach { jsonStr =>
|
||||||
try
|
try
|
||||||
val metadata = mapper.readValue(json, classOf[InstanceMetadata])
|
val metadata = mapper.readValue(jsonStr, classOf[InstanceMetadata])
|
||||||
instances.put(instanceId, metadata)
|
instances.put(instanceId, metadata)
|
||||||
log.infof("Startup: loaded instance %s from Redis", instanceId)
|
log.infof("Startup: loaded instance %s from Redis", instanceId)
|
||||||
catch
|
catch
|
||||||
case ex: Exception =>
|
case ex: Exception =>
|
||||||
log.warnf(ex, "Startup: failed to parse instance %s", instanceId)
|
log.warnf(ex, "Startup: failed to parse instance %s", instanceId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def getInstance(instanceId: String): Option[InstanceMetadata] =
|
def getInstance(instanceId: String): Option[InstanceMetadata] =
|
||||||
|
|||||||
Reference in New Issue
Block a user