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

   ## Summary
   
   Fix three confirmed bugs in `camel-braintree`:
   
   1. **NPE in `BraintreeComponent.getGateway()`** when neither `accessToken` 
nor `merchantId` is configured — `ConcurrentHashMap.computeIfAbsent(null, ...)` 
throws `NullPointerException` with no context.
   2. **Stale `methodName` enum list** in `BraintreeConfiguration.java` 
(`@UriPath` annotation) — `holdInEscrow` does not exist in the Braintree Java 
SDK; nine real methods were missing (`adjustAuthorization`, `all`, 
`connectUrl`, `createTokenFromCode`, `createTokenFromRefreshToken`, 
`packageTracking`, `parseWithoutSignatureVerification`, `reverse`, 
`revokeAccessToken`, `updateCustomFields`).
   3. **Missing `addOn` and `discount` APIs** in both `braintree.json` 
descriptors (`apis` and `apiProperties` sections) — `AddOnGatewayApiMethod` and 
`DiscountGatewayApiMethod` are registered in `BraintreeApiCollection` but were 
absent from the catalog, making these two APIs invisible to tooling.
   
   ## Root Cause
   
   1. `getGateway()` did not guard against a `null` merchantId before passing 
it as a `ConcurrentHashMap` key — a contract violation that produces an obscure 
NPE instead of a clear configuration error.
   2. The `enums` attribute of the `@UriPath methodName` annotation was 
hand-maintained and drifted from the generated `*GatewayApiMethod` enums as the 
Braintree SDK evolved.
   3. The `apis` / `apiProperties` JSON sections were generated from an older 
code generator run that pre-dates `AddOnGatewayApiMethod` and 
`DiscountGatewayApiMethod` being added to `BraintreeApiCollection`.
   
   ## Fix
   
   1. Guard `getGateway()` with an explicit null-check on `merchantId`, 
throwing `IllegalStateException` with a clear message pointing to the required 
credentials.
   2. Rebuild the `enums` list from every `*GatewayApiMethod` enum in 
`src/generated/` — 39 unique method names, alphabetically ordered, replacing 
the stale list of 31.
   3. Add `addOn` and `discount` entries (both expose only `all()`) to the 
`apis` and `apiProperties` sections of both JSON descriptor copies (component + 
catalog mirror).
   
   ## Tests
   
   `BraintreeComponentNpeTest`: verifies that calling `getGateway()` with no 
credentials throws `IllegalStateException` (not `NullPointerException`), 
covering bug 1.
   
   Existing `BraintreeComponentTest` and `BraintreeConfigurationTest` continue 
to pass.
   
   Fixes CAMEL-27970
   
   ---
   _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