allthingssecurity commented on code in PR #26770:
URL: https://github.com/apache/camel/pull/26770#discussion_r4083120997


##########
core/camel-core-processor/src/main/java/org/apache/camel/processor/loadbalancer/WeightedLoadBalancer.java:
##########
@@ -46,6 +46,24 @@ protected void doStart() throws Exception {
                     "Loadbalacing with " + getProcessors().size()
                                                + " should match number of 
distributions " + ratios.size());
         }
+        // a ratio that is negative, or ratios that are all zero or add up to 
more than an int can hold,
+        // would make the processor selection loop forever or fail on every 
exchange
+        long sum = 0;

Review Comment:
   Good point, done in 6e03b7b6: the validation now runs in the 
`WeightedLoadBalancer` constructor with a `long` sum. The constructor then sets 
`distributionRatioSum` from the validated value. So there is no int overflow 
and no second pass in `doStart()`, which keeps only the processors-vs-ratios 
count check (the processors are added after construction). Invalid ratios still 
fail the route at startup with the same `IllegalArgumentException`s. 
`*LoadBalanc*`, `*Weighted*`, `Failover*` and `FailOver*`: 65 tests, 0 failures.
   
   On the labels: I can't add labels on apache/camel. If a committer agrees, 
`port/camel-4.22.x` makes sense to me.
   
   _Claude Code on behalf of allthingssecurity_



-- 
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