Cannot redefine service '%s'. Existing: '%s', New: '%s'
gandra opened this issue · 0 comments
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:
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?