Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Potential Bug] Implicit creation of ExecutorService in LeaderSelector constructor risks thread leaks

オープン
#1,282 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
java

調査の方向性

LeaderSelector の 104 行目付近にあるコンストラクターから始め、周辺の Javadoc とオーバーロードを読みます。プロジェクトが利便性コンストラクターを非推奨にすべきか、または close() が必須であることを文書化すべきかを判断します。完了とは、選択したライフサイクルの指針がコンストラクター API のドキュメントに一貫して反映されていることです。

索引モデルが issue の本文から書いたものです。

説明

Description

The LeaderSelector class provides a convenience constructor that implicitly creates an internal ExecutorService using Executors.newSingleThreadExecutor().

Code Reference In org.apache.curator.framework.recipes.leader.LeaderSelector (Line 104):
public LeaderSelector(CuratorFramework client, String leaderPath, LeaderSelectorListener listener) {
    this(
            client,
            leaderPath,
            // Issue: Implicitly creates a thread pool that is hidden from the user
            new CloseableExecutorService(Executors.newSingleThreadExecutor(defaultThreadFactory), true),
            listener);
}
The Issue
  1. Hidden Lifecycle: Users utilizing this constructor may not be aware that a heavy resource (Thread Pool) is created internally.

  2. Thread Leak Risk: If the LeaderSelector instance is garbage collected without calling close() (e.g., during rapid Zookeeper session reconstruction or error handling flows), the internal non-daemon thread pool remains active. This leads to Thread Leaks and eventual OutOfMemoryError or thread exhaustion.

Recommendation

Deprecate this constructor to discourage implicit resource allocation.

Or, update Javadoc to explicitly warn users that close() is mandatory to release the internal threads.

Ideally, encourage Dependency Injection where the ExecutorService is passed externally.

主要言語
Java
スター
3.2k
フォーク
1.2k
平均マージ
14時間 48分
マージ済み PR(30日)
2

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/curator のほかの issue

apache/curator の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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