Skip to content

CAMEL-23295: Fix resource leak and improve error handling in camel-splunk-hec producer#22483

Merged
oscerd merged 2 commits intomainfrom
ci-issue-CAMEL-23295
Apr 8, 2026
Merged

CAMEL-23295: Fix resource leak and improve error handling in camel-splunk-hec producer#22483
oscerd merged 2 commits intomainfrom
ci-issue-CAMEL-23295

Conversation

@oscerd
Copy link
Copy Markdown
Contributor

@oscerd oscerd commented Apr 8, 2026

Summary

Claude Code on behalf of Andrea Cosentino

  • Add warning log when skipTlsVerify is enabled to alert operators that TLS verification is disabled
  • Replace generic RuntimeException with RuntimeCamelException for proper Camel error handling
  • Log error response body at DEBUG level for easier debugging of Splunk HEC failures
  • Consume response entity on success path to prevent potential connection leaks
  • Add unit tests for error handling behavior (2 tests)

Fixes: https://issues.apache.org/jira/browse/CAMEL-23295

Test plan

  • All existing tests pass (30 tests, 0 failures)
  • New SplunkHECProducerTest verifies RuntimeCamelException is thrown on 400 and 503 responses
  • @AfterEach properly closes CamelContext to prevent resource leaks in tests

🤖 Generated with Claude Code

…lunk-hec producer

- Add warning log when skipTlsVerify is enabled to alert operators
- Replace RuntimeException with RuntimeCamelException for proper Camel error handling
- Log error response body at DEBUG level for easier debugging
- Consume response entity on success path to prevent potential connection leaks
- Add unit tests for error handling behavior

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd oscerd requested a review from davsclaus April 8, 2026 07:38
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@oscerd oscerd requested review from Croway and gnodet April 8, 2026 07:39
Copy link
Copy Markdown
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Claude Code on behalf of Guillaume Nodet

Overall a solid, well-scoped bug fix. A couple of items worth addressing:

Issues

1. (Medium) Missing CamelContext cleanup in test
SplunkHECProducerTest.java@BeforeEach creates and starts a DefaultCamelContext but there is no @AfterEach to stop/close it. This leaks resources across test runs. Please add:

@AfterEach
void tearDown() {
    camelContext.close();
}

2. (Low) Third test is redundant
testExceptionTypeIsRuntimeCamelExceptionNotRuntimeException catches Exception.class and asserts the class is exactly RuntimeCamelException.class. The other two tests already use assertThrows(RuntimeCamelException.class, ...) — if the type were wrong, those would fail first. Consider removing this test to keep the test class focused.

Positives

  • RuntimeExceptionRuntimeCamelException follows Camel conventions
  • EntityUtils.consume() on the success path properly prevents connection pool leaks
  • TLS verification warning is appropriate
  • Good test coverage for the error paths

This review covers project conventions, correctness, and test coverage. It does not replace specialized tools like SonarCloud or CodeRabbit.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

🧪 CI tested the following changed modules:

  • components/camel-splunk-hec
All tested modules (7 modules)
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container
  • Camel :: Splunk HEC
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

- Add @AfterEach to close CamelContext and prevent resource leak in tests
- Remove redundant testExceptionTypeIsRuntimeCamelExceptionNotRuntimeException test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd
Copy link
Copy Markdown
Contributor Author

oscerd commented Apr 8, 2026

Claude Code on behalf of Andrea Cosentino

@gnodet Thank you for the review! Both items addressed in 3c5e848:

  1. CamelContext cleanup — Added @AfterEach with camelContext.close() to prevent resource leaks across test runs.
  2. Redundant test — Removed testExceptionTypeIsRuntimeCamelExceptionNotRuntimeException since the other two tests already verify the exception type via assertThrows(RuntimeCamelException.class, ...).

@oscerd oscerd requested a review from gnodet April 8, 2026 09:27
@oscerd oscerd merged commit 082c4d2 into main Apr 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants