googleapis / googleapis/google-http-java-client

HttpRequest#executeAsync leaks a thread on every call

オープン
#2,122 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る
priority: p3 type: bug
主要言語
Java
スター
1.4k
フォーク
473
PR マージ指標
30日以内にマージされた PR はありません

説明

The `executeAsync` method of `com.google.api.client.http.HttpRequest` currently leaks a thread on every call; this means that multiple calls to the method will eventually exhaust all memory.

A quick inspection of [the code for this method](https://github.com/googleapis/google-http-java-client/blob/main/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java#L1156-L1160) shows that it creates a new thread pool on every call, and never shuts the pool down.

### Steps to replicate

This issue can be easily replicated in a unit test; for example, the following code (added in `HttpRequestTest.java`) will fail with an `OutOfMemoryError` due to an inability to create a new thread.

```java
@Test
public void testThreadLeak() throws Exception {
for (int i = 0; i < 1000000; i++) {
RedirectTransport fakeTransport = new RedirectTransport();
HttpRequest request =
fakeTransport.createRequestFactory().buildGetRequest(new GenericUrl("http://gmail.com"));
Future resp = request.executeAsync();
resp.get();
}
}
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。