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


##########
components/camel-ai/camel-langchain4j-tokenizer/src/main/java/org/apache/camel/component/langchain4j/tokenizer/AbstractLangChain4JTokenizer.java:
##########
@@ -46,6 +47,10 @@ private void debugLog(String[] split) {
     public final String[] tokenize(Exchange exchange) {
         final String body = exchange.getIn().getBody(String.class);
 
+        if (body == null) {
+            throw new RuntimeCamelException("Cannot tokenize a null body");
+        }

Review Comment:
   ⚠️ **Missing regression test for the null-body fix on `camel-4.22.x`.**
   
   `TokenizerBodyTypesTest` (which covered `nullBodyCompletesWithException`) 
was deleted because it depends on `BodyTypes`/`BodyType` from CAMEL-25928, 
which don't exist on this branch. However, a standalone null-body test can be 
written without those annotations — the existing `LangChain4JLineTokenizerTest` 
infrastructure is sufficient.
   
   ```suggestion
           if (body == null) {
               throw new RuntimeCamelException("Cannot tokenize a null body");
           }
   
   ```
   
   Add to one of the existing tokenizer test classes (e.g. 
`LangChain4JLineTokenizerTest`) a test that sends `null` as the body and 
asserts the exchange exception is set (no hang):
   
   ```java
   @Test
   public void testNullBodySetsException() throws InterruptedException {
       Exchange result = template.send("direct:start", e -> 
e.getIn().setBody(null));
       assertNotNull(result.getException(), "Expected an exception for null 
body");
       assertInstanceOf(RuntimeCamelException.class, result.getException());
   }
   ```
   
   Without this, the CAMEL-26301 hang regression has no guard on `camel-4.22.x`.



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