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


##########
components/camel-opa/src/main/java/org/apache/camel/component/opa/OpaProducerHealthCheck.java:
##########
@@ -16,16 +16,10 @@
  */
 package org.apache.camel.component.opa;
 
-import java.net.URI;
-import java.net.http.HttpClient;
-import java.net.http.HttpRequest;
-import java.net.http.HttpResponse;
-import java.time.Duration;
 import java.util.Map;
 
 import org.apache.camel.health.HealthCheckResultBuilder;
 import org.apache.camel.impl.health.AbstractHealthCheck;
-import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;

Review Comment:
   💡 `URISupport` is no longer used here — the sanitisation now lives in 
`OpaHealthProbe.probe()`. Leftover import.
   
   ```suggestion
   ```



##########
components/camel-opa/src/main/java/org/apache/camel/component/opa/security/OpaSecurityPolicy.java:
##########
@@ -67,6 +70,7 @@ public OpaSecurityPolicy(String serverUrl, String policyPath) 
{
 
     @Override
     public void beforeWrap(Route route, NamedNode definition) {

Review Comment:
   💡 `registerHealthCheck` reads `policyPath` (via 
`OpaSecurityPolicyHealthCheck` → `URISupport.sanitizeUri(serverUrl + "/" + 
policyPath)`) before `notEmpty(policyPath, …)` validates it on line 74. If 
someone builds a policy without setting `policyPath`, the health check 
registers with an id containing `"/null"`, then the validation throws and the 
route never starts — but the garbage health check remains in the registry.
   
   Swapping the two so registration comes after validation avoids the orphan:
   
   ```suggestion
           if (evaluator == null) {
               StringHelper.notEmpty(policyPath, "policyPath", this);
           }
           registerHealthCheck(route);
   ```
   
   (The `evaluator == null` guard already prevents redundant work on repeat 
calls, so validation still runs exactly once.)



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