Skip to content

Fix client leak on BulkProcessor or Sniffer construction failure#1865

Merged
jnioche merged 1 commit intomainfrom
fix-opensearch-connection-resource-leak
Apr 2, 2026
Merged

Fix client leak on BulkProcessor or Sniffer construction failure#1865
jnioche merged 1 commit intomainfrom
fix-opensearch-connection-resource-leak

Conversation

@jnioche
Copy link
Copy Markdown
Contributor

@jnioche jnioche commented Apr 2, 2026

Summary

  • In OpenSearchConnection.getConnection(), if BulkProcessor.builder().build() or Sniffer.builder().build() throws, the already-created RestHighLevelClient (and its connection pool/threads) is leaked
  • Similarly, if Sniffer construction fails, the BulkProcessor is also leaked
  • Wrap construction in try-catch to close already-created resources on failure, with cleanup exceptions added as suppressed

Test plan

  • Verify compilation with mvn compile -pl external/opensearch -am
  • Verify existing OpenSearch integration tests pass

🤖 Generated with Claude Code

In getConnection(), if BulkProcessor.builder().build() or
Sniffer.builder().build() throws, the already-created RestHighLevelClient
(and its connection pool/threads) is leaked. Similarly, if Sniffer
construction fails, the BulkProcessor is also leaked.

Wrap construction in try-catch to close already-created resources on failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jnioche jnioche added the bug label Apr 2, 2026
@jnioche jnioche added this to the 3.5.2 milestone Apr 2, 2026
@jnioche jnioche merged commit 5e5fc3b into main Apr 2, 2026
2 checks passed
@jnioche jnioche deleted the fix-opensearch-connection-resource-leak branch April 2, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants