diff --git a/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java b/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java index 1e11a2c8c8..5954f4e2d6 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java @@ -121,7 +121,7 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat @Override public void onApplicationEvent(ContextRefreshedEvent event) { if (event.getApplicationContext().equals(this.applicationContext)) { - buildGraph(); + rebuild(); } } @@ -132,7 +132,7 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat * @see #rebuild() */ public Graph getGraph() { - if (this.graph == null) { // NOSONAR (sync) + if (this.graph == null) { this.lock.lock(); try { if (this.graph == null) { @@ -153,7 +153,13 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat * @see #getGraph() */ public Graph rebuild() { - return buildGraph(); + this.lock.lock(); + try { + return buildGraph(); + } + finally { + this.lock.unlock(); + } } /** @@ -170,7 +176,7 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat } private T enhance(T node) { - if (this.micrometerEnhancer != null) { // NOSONAR - synchronized inconsistency + if (this.micrometerEnhancer != null) { return this.micrometerEnhancer.enhance(node); } else { @@ -179,40 +185,34 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat } private Graph buildGraph() { - this.lock.lock(); - try { - if (this.micrometerEnhancer == null && MicrometerMetricsCaptorConfiguration.METER_REGISTRY_PRESENT) { - this.micrometerEnhancer = new MicrometerNodeEnhancer(this.applicationContext); - } - String implementationVersion = IntegrationGraphServer.class.getPackage().getImplementationVersion(); - if (implementationVersion == null) { - implementationVersion = "unknown - is Spring Integration running from the distribution jar?"; - } - Map descriptor = new HashMap<>(); - descriptor.put("provider", "spring-integration"); - descriptor.put("providerVersion", implementationVersion); - descriptor.put("providerFormatVersion", GRAPH_VERSION); - String name = this.applicationName; - if (name == null) { - name = this.applicationContext.getEnvironment().getProperty("spring.application.name"); - } - if (name != null) { - descriptor.put("name", name); - } - this.nodeFactory.reset(); - Collection nodes = new ArrayList<>(); - Collection links = new ArrayList<>(); - Map channelNodes = channels(nodes); - pollingAdapters(nodes, links, channelNodes); - gateways(nodes, links, channelNodes); - producers(nodes, links, channelNodes); - consumers(nodes, links, channelNodes); - this.graph = new Graph(descriptor, nodes, links); - return this.graph; + if (this.micrometerEnhancer == null && MicrometerMetricsCaptorConfiguration.METER_REGISTRY_PRESENT) { + this.micrometerEnhancer = new MicrometerNodeEnhancer(this.applicationContext); } - finally { - this.lock.unlock(); + String implementationVersion = IntegrationGraphServer.class.getPackage().getImplementationVersion(); + if (implementationVersion == null) { + implementationVersion = "unknown - is Spring Integration running from the distribution jar?"; } + Map descriptor = new HashMap<>(); + descriptor.put("provider", "spring-integration"); + descriptor.put("providerVersion", implementationVersion); + descriptor.put("providerFormatVersion", GRAPH_VERSION); + String name = this.applicationName; + if (name == null) { + name = this.applicationContext.getEnvironment().getProperty("spring.application.name"); + } + if (name != null) { + descriptor.put("name", name); + } + this.nodeFactory.reset(); + Collection nodes = new ArrayList<>(); + Collection links = new ArrayList<>(); + Map channelNodes = channels(nodes); + pollingAdapters(nodes, links, channelNodes); + gateways(nodes, links, channelNodes); + producers(nodes, links, channelNodes); + consumers(nodes, links, channelNodes); + this.graph = new Graph(descriptor, nodes, links); + return this.graph; } private Map channels(Collection nodes) { diff --git a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java index de6ed2bbb6..fd68d75433 100644 --- a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java +++ b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java @@ -171,7 +171,6 @@ public class GroovyScriptExecutingMessageProcessor extends AbstractScriptExecuti if (this.scriptClass == null || scriptSource.isModified()) { this.scriptLock.lock(); try { - // synchronized double check if (this.scriptClass == null || scriptSource.isModified()) { String className = scriptSource.suggestedClassName(); try { diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioConnection.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioConnection.java index 21afc3979d..a4685ac834 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioConnection.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioConnection.java @@ -364,7 +364,6 @@ public class TcpNioConnection extends TcpConnectionSupport { /** * Blocks until a complete message has been assembled. - * Synchronized to avoid concurrency. * @return The Message or null if no data is available. * @throws IOException an IO exception */ diff --git a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/AbstractMqttMessageHandler.java b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/AbstractMqttMessageHandler.java index a17f7f63a5..6054f6b7fe 100644 --- a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/AbstractMqttMessageHandler.java +++ b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/AbstractMqttMessageHandler.java @@ -281,7 +281,7 @@ public abstract class AbstractMqttMessageHandler extends AbstractMessageHa } protected void incrementClientInstance() { - this.clientInstance++; //NOSONAR - false positive - called from synchronized block + this.clientInstance++; } /** @@ -291,7 +291,7 @@ public abstract class AbstractMqttMessageHandler extends AbstractMessageHa * @since 4.1 */ public void setCompletionTimeout(long completionTimeout) { - this.completionTimeout = completionTimeout; // NOSONAR (sync) + this.completionTimeout = completionTimeout; } protected long getCompletionTimeout() { @@ -305,7 +305,7 @@ public abstract class AbstractMqttMessageHandler extends AbstractMessageHa * @since 5.1.10 */ public void setDisconnectCompletionTimeout(long completionTimeout) { - this.disconnectCompletionTimeout = completionTimeout; // NOSONAR (sync) + this.disconnectCompletionTimeout = completionTimeout; } protected long getDisconnectCompletionTimeout() {