Skip to content

Commit

Permalink
Update EdgeConfigWorker.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Sn0w3y committed Jan 22, 2025
1 parent d07e7e6 commit 4cb9581
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,17 @@ private boolean readConfigurations(EdgeConfig.ActualEdgeConfig.Builder builder,
continue;
}

// Prepare the fallback for null OR non-String "id"
var fallbackId = this.parent.getAllComponents().stream()
.filter(c -> config.getPid().equals(c.serviceFactoryPid())).map(c -> c.id()).findFirst()
.orElse(null);

// Read Component-ID
var componentId = switch (properties.get("id")) {
case String s -> s; // Read 'id' property
case null, default -> //
this.parent.getAllComponents().stream() //
.filter(c -> config.getPid().equals(c.serviceFactoryPid())) //
.map(c -> c.id()) //
.findFirst().orElse(null);
var idObj = properties.get("id");
var componentId = switch (idObj) {
case String s -> s; // Use 'id' if it's a proper String
case null -> fallbackId; // No 'id' => try singleton fallback
default -> fallbackId; // 'id' is non-String => also use fallback
};

if (componentId == null) {
Expand Down

0 comments on commit 4cb9581

Please sign in to comment.