[
https://issues.apache.org/jira/browse/CAMEL-26318?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrea Cosentino resolved CAMEL-26318.
--------------------------------------
Resolution: Fixed
> camel-stripe: StripeProducer should use request options instead of mutating
> JVM-global Stripe settings
> ------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26318
> URL: https://issues.apache.org/jira/browse/CAMEL-26318
> Project: Camel
> Issue Type: Bug
> Reporter: Andrea Cosentino
> Assignee: Andrea Cosentino
> Priority: Major
> Fix For: 4.18.6, 4.22.3, 4.24.0
>
>
> h3. Current behaviour
> In {{org.apache.camel.component.stripe.StripeProducer.doStart()}}
> (camel-stripe), the producer configures API access by writing to JVM-global
> static fields:
> {code:java}
> Stripe.apiKey = config.getApiKey();
> if (ObjectHelper.isNotEmpty(config.getApiBase())) {
> Stripe.overrideApiBase(config.getApiBase());
> }
> {code}
> The operation methods (such as {{handleCharges}}, {{handleCustomers}},
> {{handlePaymentIntents}}, etc.) then execute static methods on Stripe SDK
> model classes (e.g. {{Charge.create}}, {{Customer.retrieve}}), which read
> these global static properties.
> When multiple {{StripeEndpoint}} instances are configured in the same
> application with different API keys (or differing API base URLs), the
> producer started last overwrites the global settings for all endpoints in the
> process. Additionally, setting {{apiBase}} permanently changes the base URL
> for subsequent endpoints that do not specify an explicit {{apiBase}}.
> h3. Expected behaviour
> Each {{StripeProducer}} should apply endpoint-scoped {{RequestOptions}} to
> Stripe SDK calls (or use an isolated {{StripeClient}} instance) rather than
> mutating global {{Stripe}} static properties at startup.
> h3. Change
> * In {{StripeProducer}}:
> - Remove mutation of {{Stripe.apiKey}} and {{Stripe.overrideApiBase(...)}}
> in {{doStart()}}.
> - Construct an endpoint-scoped {{RequestOptions}} instance configured with
> the endpoint's {{apiKey}} and {{apiBase}}.
> - Pass the {{RequestOptions}} parameter to all Stripe SDK model calls
> across all supported operations.
> * Add unit tests in {{camel-stripe}} to verify that multiple endpoints
> configured with distinct API keys and base URLs execute independently without
> interfering with each other's configuration.
> h3. Tests
> * Unit test in {{camel-stripe}} verifying two endpoints with different API
> keys retain their respective keys during execution.
> * Unit test verifying an endpoint with a custom {{apiBase}} does not alter
> the base URL of subsequent endpoints without {{apiBase}}.
> * Verify existing Stripe integration tests pass.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)