oracle / oracle/oci-java-sdk

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

Open
#564 0 comments 3 reactions 0 assignees View on GitHub

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:
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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.