Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot redefine service '%s'. Existing: '%s', New: '%s' #564

Open
gandra opened this issue Dec 6, 2023 · 0 comments
Open

Cannot redefine service '%s'. Existing: '%s', New: '%s' #564

gandra opened this issue Dec 6, 2023 · 0 comments

Comments

@gandra
Copy link

gandra commented Dec 6, 2023

I am trying to instantiate 2 SubscriptionClient one from package com.oracle.bmc.onesubscription and another one from package com.oracle.bmc.tenantmanagercontrolplane.SubscriptionClient in different places inside same springbooot app and getting error:

java.lang.IllegalArgumentException: Cannot redefine service 'SUBSCRIPTION'. Existing: 'Services.BasicService(serviceName=SUBSCRIPTION, serviceEndpointPrefix=, serviceEndpointTemplate=https://organizations.{region}.oci.{secondLevelDomain}, endpointServiceName=null)', New: 'Services.BasicService(serviceName=SUBSCRIPTION, serviceEndpointPrefix=, serviceEndpointTemplate=https://identity.{region}.oci.{secondLevelDomain}, endpointServiceName=null)'

Here is instance 1:

try(com.oracle.bmc.onesubscription.SubscriptionClient subscriptionClient = SubscriptionClient.builder().region(provider.getRegion()).build(provider))  {
   ...
   ListSubscriptionsResponse listSubscriptionsResponse = subscriptionClient.listSubscriptions(listSubscriptionsRequest);
   ...
}

instance 2:

try(com.oracle.bmc.tenantmanagercontrolplane.SubscriptionClient subscriptionClient = com.oracle.bmc.tenantmanagercontrolplane.SubscriptionClient.builder().region(provider.getRegion()).build(provider))  {
}

Here is debug screenshot with root cause:
image

com.oracle.bmc.Services has static cache:

private static final Map<String, Service> SERVICE_CACHE = new HashMap<>();

which prevents instantiating different clients with same service name ... any idea how to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant