fix: replace null checks with Option in coordinator
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:
2026-05-13 12:44:34 +02:00
parent 81b045d01b
commit 2b04d7fa71
2 changed files with 6 additions and 4 deletions
@@ -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
@@ -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))