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 _ => ()
|
||||
|
||||
override def onClose(cause: WatcherException): Unit =
|
||||
if cause != null then
|
||||
log.warnf(cause, "Pod watch closed, restarting")
|
||||
Option(cause).foreach { ex =>
|
||||
log.warnf(ex, "Pod watch closed, restarting")
|
||||
startPodWatch()
|
||||
}
|
||||
)
|
||||
log.info("Pod watch started")
|
||||
catch
|
||||
|
||||
+3
-2
@@ -51,15 +51,16 @@ class InstanceRegistry:
|
||||
keys.asScala.foreach { key =>
|
||||
val instanceId = key.stripPrefix(s"$redisPrefix:instances:")
|
||||
val json = syncRedis.value(classOf[String]).get(key)
|
||||
if json != null then
|
||||
Option(json).foreach { jsonStr =>
|
||||
try
|
||||
val metadata = mapper.readValue(json, classOf[InstanceMetadata])
|
||||
val metadata = mapper.readValue(jsonStr, classOf[InstanceMetadata])
|
||||
instances.put(instanceId, metadata)
|
||||
log.infof("Startup: loaded instance %s from Redis", instanceId)
|
||||
catch
|
||||
case ex: Exception =>
|
||||
log.warnf(ex, "Startup: failed to parse instance %s", instanceId)
|
||||
}
|
||||
}
|
||||
|
||||
def getInstance(instanceId: String): Option[InstanceMetadata] =
|
||||
Option(instances.get(instanceId))
|
||||
|
||||
Reference in New Issue
Block a user