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

   ## Issue
   [CAMEL-24611](https://issues.apache.org/jira/browse/CAMEL-24611)
   
   ## Problem
   Several functional bugs in `camel-chatscript`:
   
   1. **`resetChat` does nothing** — `ChatScriptBot.reset()` had an empty body, 
and it was called once in the producer constructor rather than per exchange, so 
the `resetChat` option never issued a `:reset`.
   2. **`chatUserName` is ignored** — the bot was always constructed with an 
empty user name in the endpoint constructor (which runs before the option is 
bound), and `chatUserName` was read nowhere. Since the ChatScript wire format 
identifies per-user server state by user name, `?chatUserName=alice` was 
silently dropped.
   3. **No socket timeout** — `new Socket(host, port)` used no connect timeout 
and no `setSoTimeout`, so `readLine()` could block the route thread forever if 
the server accepted the connection but never replied.
   4. **Non-String body NPE** — `buildMessage` returned `null` for any 
non-String body (`byte[]`, `InputStream`, `Map`, `null`), causing a 
`NullPointerException` in `process()` instead of a clear error.
   
   ## Fix
   1. Implement `reset()` to send the `:reset` control message and call it per 
exchange from the producer when `resetChat` is set.
   2. Build the bot **lazily** with `chatUserName`, and apply it as the 
conversation user when the message does not carry one.
   3. Use a bounded connect timeout and `setSoTimeout` on the socket.
   4. Throw a clear `IllegalArgumentException` for unsupported body types.
   
   ## Testing
   - New `ChatScriptProducerTest` verifies the `chatUserName` is applied to the 
bot and that a non-String body is rejected with `IllegalArgumentException`. The 
`reset()` and socket-timeout paths are exercised against a live ChatScript 
server (the component's only pre-existing test is an IT), so they are covered 
by inspection here.
   - `mvn -Psourcecheck validate` green.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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