gnodet-bot commented on code in PR #29623:
URL: https://github.com/apache/camel/pull/29623#discussion_r4536424487


##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ChaosExploreDialog.java:
##########
@@ -175,6 +179,34 @@ List<Item> items() {
         return items;
     }
 
+    String name() {
+        return name;
+    }
+
+    /** The budget and the rules picked now. */
+    Picks picks() {
+        return new Picks(budget(), 
picked().stream().map(Item::rule).collect(Collectors.toSet()));
+    }

Review Comment:
   `Collectors.toSet()` returns a mutable `HashSet`. The `Picks` record exposes 
it through `rules()`, so a caller could mutate it and silently corrupt the 
entry stored in `lastPicks`. Wrap with `Set.copyOf()` for defensive 
immutability, consistent with how `ChaosRule` uses `Set.copyOf(b.hooks)`.
   
   ```suggestion
           return new Picks(budget(), 
Set.copyOf(picked().stream().map(Item::rule).collect(Collectors.toSet())));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to