Cannot redefine service '%s'. Existing: '%s', New: '%s'
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 243
- Forks
- 171
- Avg merge
- 30m
- Merged PRs (30d)
- 4
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with com.oracle.bmc.Services and its static SERVICE_CACHE, then trace the builders for com.oracle.bmc.onesubscription.SubscriptionClient and com.oracle.bmc.tenantmanagercontrolplane.SubscriptionClient. Reproduce the two-client initialization shown in the issue and determine how distinct service definitions should coexist; done means both clients can be instantiated in the same Spring Boot application without the Cannot redefine service error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100