Some synchronized comments clean up

This commit is contained in:
abilan
2023-06-21 13:54:23 -04:00
parent c38ed96ee9
commit a147040072
4 changed files with 39 additions and 41 deletions

View File

@@ -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 extends IntegrationNode> 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<String, Object> 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<IntegrationNode> nodes = new ArrayList<>();
Collection<LinkNode> links = new ArrayList<>();
Map<String, MessageChannelNode> 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<String, Object> 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<IntegrationNode> nodes = new ArrayList<>();
Collection<LinkNode> links = new ArrayList<>();
Map<String, MessageChannelNode> 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<String, MessageChannelNode> channels(Collection<IntegrationNode> nodes) {

View File

@@ -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 {

View File

@@ -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
*/

View File

@@ -281,7 +281,7 @@ public abstract class AbstractMqttMessageHandler<T, C> extends AbstractMessageHa
}
protected void incrementClientInstance() {
this.clientInstance++; //NOSONAR - false positive - called from synchronized block
this.clientInstance++;
}
/**
@@ -291,7 +291,7 @@ public abstract class AbstractMqttMessageHandler<T, C> 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<T, C> extends AbstractMessageHa
* @since 5.1.10
*/
public void setDisconnectCompletionTimeout(long completionTimeout) {
this.disconnectCompletionTimeout = completionTimeout; // NOSONAR (sync)
this.disconnectCompletionTimeout = completionTimeout;
}
protected long getDisconnectCompletionTimeout() {