gnodet opened a new pull request, #31287:
URL: https://github.com/apache/camel/pull/31287
## Summary
Fixes two bugs in `camel-zendesk` that made `camel.component.zendesk.token`
ineffective and
prevented the component's shared Zendesk client from ever being reused.
## Root Cause
**Bug 1 — Missing token propagation:**
`ZendeskComponent.createEndpoint()` propagated `serverUrl`, `username`,
`password`, and
`oauthToken` from component fields to the endpoint configuration, but
`token` was absent from
the list. Setting `camel.component.zendesk.token` had no effect on any
endpoint.
**Bug 2 — Shared client never reused:**
`ZendeskEndpoint.getZendesk()` reused the component's shared `Zendesk`
client only when
`getConfiguration().equals(getComponent().getConfiguration())` was true. In
normal
property-based setup, the component's configuration object is `null`
(properties bind to the
component's own fields, not to a nested configuration object), so the
equality check always
returned `false` and every endpoint created its own client.
Even when a configuration object was present, the comparison included
`methodName`, which
always differed between endpoint and component (the component's config has
no method name,
the endpoint's always has one), making the shared-client path permanently
unreachable.
## Fix
1. Add the missing `endpointConfiguration.setToken(token)` call in
`createEndpoint()`, in
line with the other four credential fields already there.
2. Replace the full-configuration equality check with
`hasMatchingConnectionSettings()`, which
compares the five connection fields (`serverUrl`, `username`, `password`,
`token`,
`oauthToken`) against the component's fields directly. `methodName` is
intentionally
excluded: it selects the API operation and has no bearing on client
identity.
## Tests
`ZendeskComponentTest` (new) covers all four scenarios:
- **Bug 1:** `tokenSetOnComponentMustBePropagatedToEndpoint` — asserts token
is non-null on the
endpoint when set on the component.
- **Bug 1 (negative):** `tokenIsNullWhenComponentHasNoToken` — asserts token
remains null when
the component has none.
- **Bug 2:** `endpointWithMatchingSettingsMustReuseComponentClient` —
injects a mock client into
the component and asserts `getApiProxy()` returns the same instance.
- **Bug 2 (negative):**
`endpointWithDifferentServerUrlMustNotReuseComponentClient` — overrides
`serverUrl` on the endpoint and asserts a fresh client is created.
Both bug tests were verified RED on the unfixed code and GREEN after the fix.
Fixes https://issues.apache.org/jira/browse/CAMEL-27971
---
_Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_
--
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]