Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.util.Arrays;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

import javax.jcr.RepositoryException;
Expand All @@ -40,7 +39,7 @@ public class JcrConsumer extends DefaultConsumer {

private Session session;
private EventListener eventListener;
private ScheduledFuture<?> sessionListenerCheckerScheduledFuture;
private ScheduledExecutorService sessionListenerCheckerExecutor;

public JcrConsumer(JcrEndpoint endpoint, Processor processor) {
super(endpoint, processor);
Expand Down Expand Up @@ -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);
}

private class JcrConsumerSessionListenerChecker implements Runnable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,8 @@ static SalesforceHttpClient createHttpClient(
int workerPoolMaxSize) {
SecurityUtils.adaptToIBMCipherNames(sslContextFactory);

final SalesforceHttpClient httpClient = new SalesforceHttpClient(
// ExecutorService lifecycle is managed by SalesforceHttpClient
final SalesforceHttpClient httpClient = new SalesforceHttpClient( // NOSONAR
context, context.getExecutorServiceManager().newThreadPool(source, "SalesforceHttpClient", workerPoolSize,
workerPoolMaxSize),
sslContextFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ protected AggregateProcessor createAggregator() throws Exception {

boolean parallel = parseBoolean(definition.getParallelProcessing(), false);
boolean shutdownThreadPool = willCreateNewThreadPool(definition, parallel);
// ExecutorService lifecycle is managed by AggregateProcessor via shutdownThreadPool flag
@SuppressWarnings("java:S2095")
ExecutorService threadPool = getConfiguredExecutorService("Aggregator", definition, parallel);
if (threadPool == null && !parallel) {
// executor service is mandatory for the Aggregator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public Processor createProcessor() throws Exception {
}
// prefer any explicit configured executor service
boolean shutdownThreadPool = willCreateNewThreadPool(definition, true);
// ExecutorService lifecycle is managed by ThreadsProcessor via shutdownThreadPool flag
@SuppressWarnings("java:S2095")
ExecutorService threadPool = getConfiguredExecutorService(name, definition, false);

// resolve what rejected policy to use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@
public class CamelYamlParser {

public List<ValidationMessage> parse(File file) throws Exception {
CamelContext camelContext = null;
try {
DefaultRegistry registry = new DefaultRegistry();
registry.addBeanRepository(new StubBeanRepository("*"));
DefaultRegistry registry = new DefaultRegistry();
registry.addBeanRepository(new StubBeanRepository("*"));

camelContext = new DefaultCamelContext(registry);
try (CamelContext camelContext = new DefaultCamelContext(registry)) {
camelContext.setAutoStartup(false);
camelContext.getCamelContextExtension().addContextPlugin(ComponentResolver.class,
(name, context) -> new StubComponent());
Expand Down Expand Up @@ -101,10 +99,6 @@ public List<ValidationMessage> parse(File file) throws Exception {
ValidationMessage vm = ValidationMessage.builder().type("parser")
.messageSupplier(() -> e.getClass().getName() + ": " + e.getMessage()).build();
return List.of(vm);
} finally {
if (camelContext != null) {
camelContext.stop();
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think this comment is very redundant and does not add value (not a blocker)

<sonar.java.source>${jdk.version}</sonar.java.source>
<!-- 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.coverage.jacoco.xmlReportPaths>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ String getModelPackage() {
abstract String getWriterPackage();

protected String generateWriter() throws MojoExecutionException {
ClassLoader classLoader;
try {
classLoader = DynamicClassLoader.createDynamicClassLoader(project.getCompileClasspathElements());
try (DynamicClassLoader classLoader
= DynamicClassLoader.createDynamicClassLoader(project.getCompileClasspathElements())) {
return doGenerateWriter(classLoader);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("DependencyResolutionRequiredException: " + e.getMessage(), e);
} catch (IOException e) {
throw new MojoExecutionException("IOException: " + e.getMessage(), e);
}
}

private String doGenerateWriter(ClassLoader classLoader) throws MojoExecutionException {
List<Path> jsonFiles;
try (Stream<Path> stream = PackageHelper.findJsonFiles(modelDir.toPath())) {
jsonFiles = stream.toList();
Expand Down
Loading