oscerd opened a new pull request, #26066:
URL: https://github.com/apache/camel/pull/26066

   ## Issue
   [CAMEL-24610](https://issues.apache.org/jira/browse/CAMEL-24610)
   
   ## Problem
   `LangChain4jWebSearchProducer.process()` passes 
`webSearchRequest.maxResults()` into
   `computeResponse(..., Integer maxResults)`, which does:
   
   ```java
   if (maxResults == 1) {   // auto-unbox of a nullable Integer
   ```
   
   In the **advanced** path — where the user supplies a custom 
`WebSearchRequest`
   (`getConfiguration().getWebSearchRequest() != null`) that does not set 
`maxResults` — langchain4j's
   `WebSearchRequest.maxResults()` is `null`, so the unboxing throws 
`NullPointerException`. The default
   builder path is safe only because the configuration `maxResults` defaults to 
`1`.
   
   ## Fix
   Null-guard the comparison (`if (maxResults != null && maxResults == 1)`), so 
a null `maxResults` falls
   through to the multi-result branch.
   
   ## Testing
   - New `LangChain4jWebSearchCustomRequestTest` drives the advanced path with 
a custom `WebSearchRequest`
     that omits `maxResults`; verified it fails with the described NPE against 
the unpatched code and passes
     with the fix.
   - `mvn -Psourcecheck validate` green.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01Ka4dAcJMpxahMfk3kmG5Ls


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