Andrea Cosentino created CAMEL-24611:
----------------------------------------
Summary: camel-chatscript: multiple functional bugs (resetChat
no-op, chatUserName ignored, no socket timeout, non-String body NPE)
Key: CAMEL-24611
URL: https://issues.apache.org/jira/browse/CAMEL-24611
Project: Camel
Issue Type: Bug
Components: camel-ai
Reporter: Andrea Cosentino
Assignee: Andrea Cosentino
Fix For: 4.23.0
An audit of camel-chatscript found several functional bugs:
1. ChatScriptBot.reset() has an empty body, so the resetChat endpoint option
does nothing - no :reset is ever sent to the ChatScript server. It is also
invoked once in the ChatScriptProducer constructor rather than per exchange, so
even the documented 'everytime' semantics is wrong.
2. The chatUserName endpoint option is never applied: ChatScriptEndpoint always
builds new ChatScriptBot(host, port, botName, "") with an empty user name, and
getChatUserName() is read nowhere. Since the ChatScript wire format identifies
per-user server state by user name, ?chatUserName=alice is silently ignored and
the conversation identity is wrong.
3. ChatScriptBot.doMessage opens new Socket(host, port) with no connect timeout
and never calls setSoTimeout, so in.readLine() blocks the route thread
indefinitely if the server accepts the connection but never replies.
4. ChatScriptProducer.buildMessage returns null for any non-String body
(byte[], InputStream, Map, null), causing a NullPointerException at process()
(inputMessage.setBotName(...)) instead of a clear error. (Separately, a plain
non-JSON String body reaches mapper.readValue and throws a parse exception, so
plain text is unsupported despite the 'json or the object itself' comment.)
Two further items were noted: the first message body is dropped by the init
handshake (ChatScriptBot.init forces the body to null - needs a design decision
on whether that handshake is intended), and sendChat(String) calls init(null)
which would NPE (latent; not reachable through the producer, which uses the
ChatScriptMessage overload).
_Reported by an automated functional audit._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)