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

   ## Summary
   
   Fix two bugs in `TwilioComponent`:
   1. The component `configuration` field shadowed the parent 
`AbstractApiComponent.configuration`, so `setConfiguration()` never reached the 
superclass and endpoints never received component-level configuration.
   2. The credential validation check used `&&` instead of `||`, allowing a 
username-only (or password-only) configuration to pass the start check and then 
fail at runtime with an NPE or HTTP 401.
   
   ## Root Cause
   
   **Bug 1 — configuration shadowing:**
   `TwilioComponent` declared its own `private TwilioConfiguration 
configuration` field with the same name as the protected field in 
`AbstractApiComponent`. The overridden 
`getConfiguration()`/`setConfiguration()` methods only touched the subclass 
field, while `AbstractApiComponent.createEndpointConfiguration()` reads 
`this.configuration` (the parent field, always `null`). No component-level 
options were ever copied to endpoints.
   
   **Bug 2 — wrong boolean operator:**
   ```java
   // Before (bug): passes when only one credential is set
   if (ObjectHelper.isEmpty(username) && ObjectHelper.isEmpty(password)) {
   // After (fix): rejects when either credential is missing
   if (ObjectHelper.isEmpty(username) || ObjectHelper.isEmpty(password)) {
   ```
   
   ## Fix
   
   - Remove the shadowing `private TwilioConfiguration configuration` field and 
its `@Metadata` annotation.
   - Delegate `getConfiguration()` and `setConfiguration()` to `super` so the 
superclass field is used.
   - Change `&&` to `||` in the credential check in `doStart()`.
   
   ## Tests
   
   Added `TwilioComponentTest` with four unit tests (no Twilio credentials 
needed):
   - `testSetConfigurationIsVisibleToSuperclass` — verifies that 
`setConfiguration()` is reflected by `getConfiguration()` (regression for bug 
1).
   - `testStartFailsWithUsernameOnly` — verifies that username without password 
throws `IllegalStateException` (regression for bug 2).
   - `testStartFailsWithPasswordOnly` — symmetric case: password without 
username is also rejected.
   - `testStartFailsWithNoCredentials` — verifies the pre-existing 
no-credentials rejection is preserved.
   
   Fixes CAMEL-27976
   
   ---
   _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]

Reply via email to