[
https://issues.apache.org/jira/browse/CAMEL-27684?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27684:
--------------------------------
Fix Version/s: 4.25.0
(was: 4.24.0)
> camel-xmpp: anonymous login, producer JIDs, pubsub duplicates, startup,
> header metadata
> ---------------------------------------------------------------------------------------
>
> Key: CAMEL-27684
> URL: https://issues.apache.org/jira/browse/CAMEL-27684
> Project: Camel
> Issue Type: Bug
> Components: camel-xmpp
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-xmpp for CAMEL-23832
> (commit
> https://github.com/apache/camel/commit/3c9b1a51ddac19a018e297f7aa17e781aebf9fa1).
> These are separate problems of the component; the descriptions commit only
> documents the current behavior.
> h4. 1. Anonymous login fails with the default connection
> Without the {{user}} option, {{XmppEndpoint.login()}} calls Smack's
> {{connection.login()}} without a user name. The connection configuration that
> {{XmppEndpoint.createConnectionInternal()}} builds does not call
> {{performSaslAnonymousAuthentication()}}, so Smack 4.4.8 throws
> {{IllegalArgumentException: Username must not be null nor empty}} and the
> consumer or producer fails to start. An anonymous login only works with a
> {{connectionConfig}} that enables it.
> Proposed change: call {{performSaslAnonymousAuthentication()}} on the built
> configuration when no user is set.
> h4. 2. The private chat producer does not resolve a participant without a
> domain
> {{XmppPrivateChatProducer.process()}} uses {{endpoint.getParticipant()}} as
> it is: {{JidCreate.entityBareFrom("bob")}} throws {{XmppStringprepException:
> localpart can't be null}}, so every message fails. The consumer completes the
> same name with the XMPP domain of the server
> ({{XmppEndpoint.resolveParticipant()}}). Without a participant, the producer
> falls back to the {{user}} option, which is a localpart, and fails the same
> way.
> Proposed change: use {{resolveParticipant(connection)}} in the producer too.
> h4. 3. The room producer fails every message without a user
> {{XmppGroupChatProducer.process()}} calls
> {{message.setFrom(JidCreate.from(endpoint.getUser()))}}, which throws a
> NullPointerException when {{user}} is not set. Without {{nickname}}, the
> nickname falls back to the user, and {{Resourcepart.from(null)}} fails when
> the producer enters the room.
> Proposed change: do not set the from address (the server sets it), and
> require a nickname when there is no user.
> h4. 4. A pubsub consumer routes a normal chat message twice
> With {{pubsub=true}}, {{XmppConsumer.subscribe()}} adds a stanza listener for
> messages of type headline or normal, and also the chat manager's incoming
> listener, which gets messages of type normal or chat that have a body. A
> {{normal}} message with a body (the type that {{XmppPrivateChatProducer}}
> sends) is routed by both. The stanza listener also skips the participant
> filter of {{newIncomingMessage()}}.
> Proposed change: let the pubsub listener skip the messages that the chat
> manager handles (for example messages with a body from a full JID), or route
> each stanza only once.
> h4. 5. testConnectionOnStartup=false defers the first start only on a
> SmackException
> {{XmppConsumer.doStart()}}, {{XmppPrivateChatProducer.doStart()}} and
> {{XmppGroupChatProducer.doStart()}} only catch {{SmackException}}. A failed
> login ({{XMPPException}}, for example a SASL failure), an {{IOException}}, or
> a refused room entry fails the start even with
> {{testConnectionOnStartup=false}}, while the consumer's delayed start
> (CAMEL-27506) tries again after any of them.
> Proposed change: with {{testConnectionOnStartup=false}}, handle every failure
> of the first start like the delayed start does.
> h4. 6. testConnectionOnStartup has no effect on the doc and pubsub producers
> {{XmppDirectProducer}} and {{XmppPubSubProducer}} have no {{doStart()}}: they
> always connect at the first message, also when
> {{testConnectionOnStartup=true}}.
> Proposed change: connect in {{doStart()}} as the chat producers do.
> h4. 7. createAccount=true fails once the account exists
> {{XmppEndpoint.createConnection()}} calls {{AccountManager.createAccount()}}
> for every new connection. Once the account exists, the server answers with an
> error (conflict), Smack throws {{XMPPErrorException}}, and the connection
> fails, so the route fails to start at every restart after the first.
> Proposed change: ignore a conflict error of the registration and go on with
> the login.
> h4. 8. The doc option has label consumer
> The producer uses {{doc}} too: {{XmppEndpoint.createProducer()}} picks
> {{XmppDirectProducer}} when it is true. The label should be {{common}}.
> h4. 9. Undocumented headers
> {{XmppBinding.extractHeadersFromXmpp()}} sets {{CamelXmppMessageType}},
> {{CamelXmppSubject}}, {{CamelXmppThreadID}}, {{CamelXmppFrom}},
> {{CamelXmppStanzaID}}, {{CamelXmppTo}} and the deprecated
> {{CamelXmppPacketID}}, but only {{CamelXmppDoc}} has {{@Metadata}} in
> {{XmppConstants}}, so the others are not in the catalog or the docs.
> {{XmppBinding.populateXmppMessage()}} also reads the {{subject}} and
> {{language}} headers, which are not documented either.
> h4. 10. CamelXmppDoc header metadata
> The header has label {{consumer}} and javaType
> {{org.jivesoftware.smack.packet.Message}}, but
> {{XmppPubSubProducer.process()}} sets it too, to the {{PubSub}} packet that
> it sends.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)