From 28cbc2e18447aa8a04a5868889a49b555075d0c6 Mon Sep 17 00:00:00 2001 From: Janis Eccarius Date: Sun, 21 Jun 2026 21:50:00 +0200 Subject: [PATCH] fix(tournament): use Optional[String] for selfUrl ConfigProperty to avoid startup failure Empty string config value caused DeploymentException when injected as String. Optional[String] handles absent/empty cleanly without defaultValue workaround. Co-Authored-By: Claude Sonnet 4.6 --- .../tournament/resource/TournamentResource.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/tournament/src/main/scala/de/nowchess/tournament/resource/TournamentResource.scala b/modules/tournament/src/main/scala/de/nowchess/tournament/resource/TournamentResource.scala index ce8f0de..3f2eeee 100644 --- a/modules/tournament/src/main/scala/de/nowchess/tournament/resource/TournamentResource.scala +++ b/modules/tournament/src/main/scala/de/nowchess/tournament/resource/TournamentResource.scala @@ -16,6 +16,7 @@ import jakarta.ws.rs.* import jakarta.ws.rs.core.{Context, HttpHeaders, MediaType, Response, StreamingOutput} import org.eclipse.microprofile.config.inject.ConfigProperty import org.eclipse.microprofile.jwt.JsonWebToken +import java.util.Optional import org.jboss.logging.Logger import scala.compiletime.uninitialized import scala.jdk.CollectionConverters.* @@ -37,8 +38,8 @@ class TournamentResource: @Inject var objectMapper: ObjectMapper = uninitialized @Context var headers: HttpHeaders = uninitialized - @ConfigProperty(name = "nowchess.tournament.self-url", defaultValue = "") - var selfUrl: String = uninitialized + @ConfigProperty(name = "nowchess.tournament.self-url") + var selfUrl: Optional[String] = uninitialized // scalafix:on @GET @@ -88,11 +89,12 @@ class TournamentResource: val userId = Option(jwt.getSubject).getOrElse("") val form = CreateTournamentForm(name, nbRounds, clockLimit, clockIncrement, rated) val t = tournamentService.create(userId, form) - if selfUrl.nonEmpty then + selfUrl.ifPresent { url => registry.serverUrls().foreach { remoteUrl => - if !externalClient.replicateTournament(remoteUrl, toReplicateRequest(t), selfUrl) then + if !externalClient.replicateTournament(remoteUrl, toReplicateRequest(t), url) then log.warnf("Failed to replicate tournament %s to %s", t.id, remoteUrl) } + } Response.status(Response.Status.CREATED).entity(tournamentService.toDto(t)).build() @GET