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

未关闭
#564 0 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
java
领域
api, backend

调研方向

从 com.oracle.bmc.Services 及其静态 SERVICE_CACHE 开始,然后跟踪 com.oracle.bmc.onesubscription.SubscriptionClient 和 com.oracle.bmc.tenantmanagercontrolplane.SubscriptionClient 的 builder。复现 issue 中所示的双客户端初始化,并确定不同的服务定义应如何共存;完成标准是两个客户端都能在同一个 Spring Boot 应用程序中实例化,且不会出现 Cannot redefine service 错误。

由索引模型根据 Issue 内容生成。

描述

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?

主要语言
Java
星标
243
派生
171
平均合并
5 分钟
30 天内合并 PR
4

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

oracle/oci-java-sdk 的其他 Issue

查看 oracle/oci-java-sdk 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。