googleapis / googleapis/google-cloud-java

[sdk-platform-java] com.google.api.gax.httpjson.ManagedHttpJsonInterceptorChannel does not close the channels correctly

未关闭
#12,368 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
priority: p3 type: bug
主要语言
Java
星标
2.1k
派生
1.2k
平均合并
1 天 23 小时
30 天内合并 PR
157

描述

#### Environment details

1. Specify the artifact at the beginning of the title. For example, "api-common", "gax" etc)
2. OS type and version: Linux Debian 6.1.158-1 (2025-11-09) x86_64 GNU/Linux
3. Java version: openjdk version "11.0.20.1" 2023-08-24
4. artifact version(s): 2.63.1

#### Steps to reproduce

1. Created a GCP API stub which uses "defaultHttpJsonTransportProviderBuilder" and creates an "InstantiatingHttpJsonChannelProvider"
2. On the client close, the close is successfully but the executor service is not being deleted.

#### Code example

```java
ManagedHttpJsonInterceptorChannel(
ManagedHttpJsonChannel channel, HttpJsonClientInterceptor interceptor) {
super();
this.channel = channel;
this.interceptor = interceptor;
}

@Override
public synchronized void shutdown() {
channel.shutdown();
}
```

super() calls ManagedHttpJsonChannel which creates a fixed executor service that never gets deleted.
```
protected ManagedHttpJsonChannel() {
this(null, true, null, null);
}

private ManagedHttpJsonChannel(
Executor executor,
boolean usingDefaultExecutor,
String endpoint,
@Nullable HttpTransport httpTransport) {
this.executor = executor;
this.usingDefaultExecutor = usingDefaultExecutor;
this.endpoint = endpoint;
this.httpTransport = httpTransport == null ? new NetHttpTransport() : httpTransport;
this.deadlineScheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
}
```

Ideally we should call:
```
@Override
public synchronized void shutdown() {
super.shutdown();
channel.shutdown();
}
```
Same applies to shutdownNow(), close()

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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