You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/03/30 15:03:49 UTC
[PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
gnodet opened a new pull request, #22343:
URL: https://github.com/apache/camel/pull/22343
## Summary
Fix all 31 SonarCloud blocker reliability issues ([java:S2095](https://sonarcloud.io/project/issues?impactSeverities=BLOCKER&impactSoftwareQualities=RELIABILITY&issueStatuses=OPEN%2CCONFIRMED&id=apache_camel) — resource leaks):
- **JcrConsumer**: `ScheduledExecutorService` created as local variable but never stored or shut down. Fixed by storing in a field and shutting down via `ExecutorServiceManager.shutdownNow()` in `cancelSessionListenerChecker()`
- **ModelWriterGeneratorMojo**: `DynamicClassLoader` (extends `URLClassLoader`) never closed. Fixed with try-with-resources
- **23 HttpClient false positives**: Set `sonar.java.source=17` so SonarCloud analyzes against the correct API surface (HttpClient only implements AutoCloseable since Java 21, but project compiles with `--release 17`)
- **6 ExecutorService/CamelContext false positives**: Added `@SuppressWarnings("java:S2095")` with explanatory comments on `AggregateReifier`, `ThreadsReifier`, `SalesforceComponent`, and `CamelYamlParser`
## Test plan
- [ ] CI passes — changes are minimal (1 real bug fix, 1 resource cleanup, rest are annotations/config)
- [ ] Verify SonarCloud blocker count drops to 0 after merge
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #22343:
URL: https://github.com/apache/camel/pull/22343#discussion_r3010558609
##########
components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrConsumer.java:
##########
@@ -157,20 +156,23 @@ private void unregisterListenerAndLogoutSession() throws RepositoryException {
}
private void cancelSessionListenerChecker() {
- if (sessionListenerCheckerScheduledFuture != null) {
- sessionListenerCheckerScheduledFuture.cancel(true);
+ if (sessionListenerCheckerExecutor != null) {
+ getJcrEndpoint().getCamelContext().getExecutorServiceManager()
+ .shutdownNow(sessionListenerCheckerExecutor);
+ sessionListenerCheckerExecutor = null;
}
}
private void scheduleSessionListenerChecker() {
String name = "JcrConsumerSessionChecker[" + getJcrEndpoint().getEndpointConfiguredDestinationName() + "]";
- ScheduledExecutorService executor = getJcrEndpoint().getCamelContext().getExecutorServiceManager()
+ sessionListenerCheckerExecutor = getJcrEndpoint().getCamelContext().getExecutorServiceManager()
.newSingleThreadScheduledExecutor(this, name);
JcrConsumerSessionListenerChecker sessionListenerChecker = new JcrConsumerSessionListenerChecker();
long sessionLiveCheckIntervalOnStart = JcrConsumer.this.getJcrEndpoint().getSessionLiveCheckIntervalOnStart();
long sessionLiveCheckInterval = JcrConsumer.this.getJcrEndpoint().getSessionLiveCheckInterval();
- sessionListenerCheckerScheduledFuture = executor.scheduleWithFixedDelay(sessionListenerChecker,
- sessionLiveCheckIntervalOnStart, sessionLiveCheckInterval, TimeUnit.MILLISECONDS);
+ sessionListenerCheckerExecutor.scheduleWithFixedDelay(
+ sessionListenerChecker, sessionLiveCheckIntervalOnStart, sessionLiveCheckInterval,
+ TimeUnit.MILLISECONDS);
Review Comment:
so first I do not understand very well this part of the code.
wonderign if we are not supposed to check if `sessionListenerCheckerExecutor` is not already in use, otherwise we will lost the reference to it and so cannot cancel or unregister it later on. (butit seems there was the same kind of issue before)
##########
pom.xml:
##########
@@ -122,6 +122,7 @@
<!-- NOTE: this is required to correctly map each module coverage in Sonarqube. The ${maven.multiModuleProjectDirectory} may require some change
when upgrading to Maven 4.x, according to any of the new variables that will replace this one. -->
+ <sonar.java.source>${jdk.version}</sonar.java.source>
<sonar.coverage.jacoco.xmlReportPaths>
${maven.multiModuleProjectDirectory}/coverage/target/site/jacoco-aggregate/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
Review Comment:
the comment is only for the sonar.coverage.jacoco.xmlReportPaths , not for the sonar.java.source, so I think it will be clearer to keep the comment right above the sonar.coverage.jacoco.xmlReportPaths
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #22343:
URL: https://github.com/apache/camel/pull/22343#issuecomment-4155934563
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: 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 `build-all`, `build-dependents`, `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](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #22343:
URL: https://github.com/apache/camel/pull/22343#discussion_r3010740979
##########
pom.xml:
##########
@@ -122,6 +122,7 @@
<!-- NOTE: this is required to correctly map each module coverage in Sonarqube. The ${maven.multiModuleProjectDirectory} may require some change
when upgrading to Maven 4.x, according to any of the new variables that will replace this one. -->
+ <sonar.java.source>${jdk.version}</sonar.java.source>
<sonar.coverage.jacoco.xmlReportPaths>
${maven.multiModuleProjectDirectory}/coverage/target/site/jacoco-aggregate/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
Review Comment:
Good point — moved `sonar.java.source` above the NOTE comment so it stays directly above `sonar.coverage.jacoco.xmlReportPaths` where it belongs. Also added a separate comment for `sonar.java.source`. Fixed in 9271179.
_Claude Code on behalf of Guillaume Nodet_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #22343:
URL: https://github.com/apache/camel/pull/22343#issuecomment-4155872437
> Would it make sense to use `${jdk.version}` here?
Good catch @Croway — changed to `${jdk.version}` for consistency with the other compiler settings. Fixed in 769137a.
_Claude Code on behalf of Guillaume Nodet_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #22343:
URL: https://github.com/apache/camel/pull/22343#issuecomment-4197448573
> i think this comment is very redundant and does not add value
Agreed — removed the comment. The property name is self-explanatory. Fixed in c51c8b0.
_Claude Code on behalf of Guillaume Nodet_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on PR #22343:
URL: https://github.com/apache/camel/pull/22343#issuecomment-4162988387
/component-test jcr salesforce
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "squakez (via GitHub)" <gi...@apache.org>.
squakez commented on code in PR #22343:
URL: https://github.com/apache/camel/pull/22343#discussion_r3010559773
##########
components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java:
##########
@@ -958,6 +958,7 @@ public RawClient createRawClientFor(SalesforceEndpoint endpoint) throws Salesfor
return new DefaultRawClient(httpClient, "", session, loginConfig);
}
+ @SuppressWarnings("java:S2095") // ExecutorService lifecycle is managed by SalesforceHttpClient
Review Comment:
Adding the note at method level can include future maintenance problems if, for example, in the future the method includes a real connection leak which won't be notified as we're suppress warning at this level. IMO, these kinds of notes should be added at line level. If you check the rest of the code, the majority of time we're adding a`// NOSONAR` line on the affected line and above it another comment note explaining why this specific line should not appear in the sonar lint.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #22343:
URL: https://github.com/apache/camel/pull/22343#discussion_r3016231730
##########
pom.xml:
##########
@@ -120,6 +120,8 @@
<!-- reproducible builds: https://maven.apache.org/guides/mini/guide-reproducible-builds.html -->
<project.build.outputTimestamp>2026-02-17T16:11:10Z</project.build.outputTimestamp>
+ <!-- Tell SonarCloud which Java source level to use for analysis -->
Review Comment:
i think this comment is very redundant and does not add value (not a blocker)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #22343:
URL: https://github.com/apache/camel/pull/22343#issuecomment-4199989263
## [](https://sonarcloud.io/dashboard?id=apache_camel&pullRequest=22343) **Quality Gate failed**
Failed conditions
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_camel&pullRequest=22343&metric=new_coverage&view=list) (required ≥ 80%)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_camel&pullRequest=22343)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #22343:
URL: https://github.com/apache/camel/pull/22343
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #22343:
URL: https://github.com/apache/camel/pull/22343#discussion_r3010471985
##########
pom.xml:
##########
@@ -122,6 +122,7 @@
<!-- NOTE: this is required to correctly map each module coverage in Sonarqube. The ${maven.multiModuleProjectDirectory} may require some change
when upgrading to Maven 4.x, according to any of the new variables that will replace this one. -->
+ <sonar.java.source>17</sonar.java.source>
Review Comment:
Would it make sense to use `${jdk.version}` here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #22343:
URL: https://github.com/apache/camel/pull/22343#discussion_r3010742165
##########
components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrConsumer.java:
##########
@@ -157,20 +156,23 @@ private void unregisterListenerAndLogoutSession() throws RepositoryException {
}
private void cancelSessionListenerChecker() {
- if (sessionListenerCheckerScheduledFuture != null) {
- sessionListenerCheckerScheduledFuture.cancel(true);
+ if (sessionListenerCheckerExecutor != null) {
+ getJcrEndpoint().getCamelContext().getExecutorServiceManager()
+ .shutdownNow(sessionListenerCheckerExecutor);
+ sessionListenerCheckerExecutor = null;
}
}
private void scheduleSessionListenerChecker() {
String name = "JcrConsumerSessionChecker[" + getJcrEndpoint().getEndpointConfiguredDestinationName() + "]";
- ScheduledExecutorService executor = getJcrEndpoint().getCamelContext().getExecutorServiceManager()
+ sessionListenerCheckerExecutor = getJcrEndpoint().getCamelContext().getExecutorServiceManager()
.newSingleThreadScheduledExecutor(this, name);
JcrConsumerSessionListenerChecker sessionListenerChecker = new JcrConsumerSessionListenerChecker();
long sessionLiveCheckIntervalOnStart = JcrConsumer.this.getJcrEndpoint().getSessionLiveCheckIntervalOnStart();
long sessionLiveCheckInterval = JcrConsumer.this.getJcrEndpoint().getSessionLiveCheckInterval();
- sessionListenerCheckerScheduledFuture = executor.scheduleWithFixedDelay(sessionListenerChecker,
- sessionLiveCheckIntervalOnStart, sessionLiveCheckInterval, TimeUnit.MILLISECONDS);
+ sessionListenerCheckerExecutor.scheduleWithFixedDelay(
+ sessionListenerChecker, sessionLiveCheckIntervalOnStart, sessionLiveCheckInterval,
+ TimeUnit.MILLISECONDS);
Review Comment:
The `sessionListenerCheckerExecutor` is managed by two methods: `scheduleSessionListenerChecker` (called in `doStart`) and `cancelSessionListenerChecker` (called in `doStop`).
The original problem was that the `ScheduledExecutorService` was created as a **local variable** in `scheduleSessionListenerChecker()` — only the `ScheduledFuture` was stored and cancelled in `doStop`. The executor itself was never shut down, which is the resource leak SonarCloud flagged.
The fix stores the executor in a field instead and shuts it down properly via `ExecutorServiceManager.shutdownNow()` in `cancelSessionListenerChecker()`. Since `shutdownNow()` cancels all scheduled tasks, the separate `ScheduledFuture` field is no longer needed.
Regarding your question about the guard: since `scheduleSessionListenerChecker()` is only called from `doStart()` and `cancelSessionListenerChecker()` from `doStop()`, Camel's lifecycle guarantees they are called in order, so the executor should always be null when entering `scheduleSessionListenerChecker()`. But I can add a defensive check if you prefer.
_Claude Code on behalf of Guillaume Nodet_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #22343:
URL: https://github.com/apache/camel/pull/22343#discussion_r3010745966
##########
components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java:
##########
@@ -958,6 +958,7 @@ public RawClient createRawClientFor(SalesforceEndpoint endpoint) throws Salesfor
return new DefaultRawClient(httpClient, "", session, loginConfig);
}
+ @SuppressWarnings("java:S2095") // ExecutorService lifecycle is managed by SalesforceHttpClient
Review Comment:
Good point — replaced with a line-level `// NOSONAR` on the specific line, with an explanatory comment above it. This avoids masking future real leaks in the method. Fixed in 9271179.
_Claude Code on behalf of Guillaume Nodet_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23271: Fix SonarCloud blocker reliability issues (resource leaks) [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #22343:
URL: https://github.com/apache/camel/pull/22343#issuecomment-4163055093
:white_check_mark: `/component-test jcr salesforce` tests passed successfully.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org