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


##########
components/camel-ai/camel-ai-tool/src/main/java/org/apache/camel/component/ai/tool/AiToolEndpoint.java:
##########
@@ -51,6 +51,8 @@ public class AiToolEndpoint extends DefaultEndpoint {
     @UriParam(description = "Tool configuration including tags, description, 
and parameter definitions.")
     private AiToolConfiguration configuration;
 

Review Comment:
   ⚠️ **Concurrency: `consumer` field needs `volatile`**
   
   `consumer` is written by `createConsumer()` (route setup thread) and read by 
`doStart()` and `doStop()` (lifecycle thread). Without `volatile`, the JMM does 
not guarantee that the lifecycle thread will ever see the write — the JIT is 
free to cache the pre-assignment `null`. Camel's `RouteService` lock does 
provide a happens-before edge in the normal startup path, but route reload and 
dynamic route addition go through different code paths where that guarantee may 
not hold.
   
   ```suggestion
       private volatile AiToolConsumer consumer;
   ```



##########
components/camel-ai/camel-ai-resource/src/main/java/org/apache/camel/component/ai/resource/AiResourceEndpoint.java:
##########
@@ -51,6 +51,8 @@ public class AiResourceEndpoint extends DefaultEndpoint {
     @UriParam(description = "Resource configuration including the resource 
uri, tags, description and MIME type.")
     private AiResourceConfiguration configuration;
 

Review Comment:
   ⚠️ **Same issue as `AiToolEndpoint.consumer`** — `consumer` is written from 
the setup thread and read from the lifecycle thread; needs `volatile`.
   
   ```suggestion
       private volatile AiResourceConsumer consumer;
   ```



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