Skip to content

Commit a147040

Browse files
committed
Some synchronized comments clean up
1 parent c38ed96 commit a147040

File tree

4 files changed

+39
-41
lines changed

4 files changed

+39
-41
lines changed

spring-integration-core/src/main/java/org/springframework/integration/graph/IntegrationGraphServer.java

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void setAdditionalPropertiesCallback(@Nullable Function<NamedComponent,
121121
@Override
122122
public void onApplicationEvent(ContextRefreshedEvent event) {
123123
if (event.getApplicationContext().equals(this.applicationContext)) {
124-
buildGraph();
124+
rebuild();
125125
}
126126
}
127127

@@ -132,7 +132,7 @@ public void onApplicationEvent(ContextRefreshedEvent event) {
132132
* @see #rebuild()
133133
*/
134134
public Graph getGraph() {
135-
if (this.graph == null) { // NOSONAR (sync)
135+
if (this.graph == null) {
136136
this.lock.lock();
137137
try {
138138
if (this.graph == null) {
@@ -153,7 +153,13 @@ public Graph getGraph() {
153153
* @see #getGraph()
154154
*/
155155
public Graph rebuild() {
156-
return buildGraph();
156+
this.lock.lock();
157+
try {
158+
return buildGraph();
159+
}
160+
finally {
161+
this.lock.unlock();
162+
}
157163
}
158164

159165
/**
@@ -170,7 +176,7 @@ protected <T> Map<String, T> getBeansOfType(Class<T> type) {
170176
}
171177

172178
private <T extends IntegrationNode> T enhance(T node) {
173-
if (this.micrometerEnhancer != null) { // NOSONAR - synchronized inconsistency
179+
if (this.micrometerEnhancer != null) {
174180
return this.micrometerEnhancer.enhance(node);
175181
}
176182
else {
@@ -179,40 +185,34 @@ private <T extends IntegrationNode> T enhance(T node) {
179185
}
180186

181187
private Graph buildGraph() {
182-
this.lock.lock();
183-
try {
184-
if (this.micrometerEnhancer == null && MicrometerMetricsCaptorConfiguration.METER_REGISTRY_PRESENT) {
185-
this.micrometerEnhancer = new MicrometerNodeEnhancer(this.applicationContext);
186-
}
187-
String implementationVersion = IntegrationGraphServer.class.getPackage().getImplementationVersion();
188-
if (implementationVersion == null) {
189-
implementationVersion = "unknown - is Spring Integration running from the distribution jar?";
190-
}
191-
Map<String, Object> descriptor = new HashMap<>();
192-
descriptor.put("provider", "spring-integration");
193-
descriptor.put("providerVersion", implementationVersion);
194-
descriptor.put("providerFormatVersion", GRAPH_VERSION);
195-
String name = this.applicationName;
196-
if (name == null) {
197-
name = this.applicationContext.getEnvironment().getProperty("spring.application.name");
198-
}
199-
if (name != null) {
200-
descriptor.put("name", name);
201-
}
202-
this.nodeFactory.reset();
203-
Collection<IntegrationNode> nodes = new ArrayList<>();
204-
Collection<LinkNode> links = new ArrayList<>();
205-
Map<String, MessageChannelNode> channelNodes = channels(nodes);
206-
pollingAdapters(nodes, links, channelNodes);
207-
gateways(nodes, links, channelNodes);
208-
producers(nodes, links, channelNodes);
209-
consumers(nodes, links, channelNodes);
210-
this.graph = new Graph(descriptor, nodes, links);
211-
return this.graph;
188+
if (this.micrometerEnhancer == null && MicrometerMetricsCaptorConfiguration.METER_REGISTRY_PRESENT) {
189+
this.micrometerEnhancer = new MicrometerNodeEnhancer(this.applicationContext);
212190
}
213-
finally {
214-
this.lock.unlock();
191+
String implementationVersion = IntegrationGraphServer.class.getPackage().getImplementationVersion();
192+
if (implementationVersion == null) {
193+
implementationVersion = "unknown - is Spring Integration running from the distribution jar?";
194+
}
195+
Map<String, Object> descriptor = new HashMap<>();
196+
descriptor.put("provider", "spring-integration");
197+
descriptor.put("providerVersion", implementationVersion);
198+
descriptor.put("providerFormatVersion", GRAPH_VERSION);
199+
String name = this.applicationName;
200+
if (name == null) {
201+
name = this.applicationContext.getEnvironment().getProperty("spring.application.name");
215202
}
203+
if (name != null) {
204+
descriptor.put("name", name);
205+
}
206+
this.nodeFactory.reset();
207+
Collection<IntegrationNode> nodes = new ArrayList<>();
208+
Collection<LinkNode> links = new ArrayList<>();
209+
Map<String, MessageChannelNode> channelNodes = channels(nodes);
210+
pollingAdapters(nodes, links, channelNodes);
211+
gateways(nodes, links, channelNodes);
212+
producers(nodes, links, channelNodes);
213+
consumers(nodes, links, channelNodes);
214+
this.graph = new Graph(descriptor, nodes, links);
215+
return this.graph;
216216
}
217217

218218
private Map<String, MessageChannelNode> channels(Collection<IntegrationNode> nodes) {

spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ private void parseScriptIfNecessary(ScriptSource scriptSource) {
171171
if (this.scriptClass == null || scriptSource.isModified()) {
172172
this.scriptLock.lock();
173173
try {
174-
// synchronized double check
175174
if (this.scriptClass == null || scriptSource.isModified()) {
176175
String className = scriptSource.suggestedClassName();
177176
try {

spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNioConnection.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ private boolean dataAvailable() {
364364

365365
/**
366366
* Blocks until a complete message has been assembled.
367-
* Synchronized to avoid concurrency.
368367
* @return The Message or null if no data is available.
369368
* @throws IOException an IO exception
370369
*/

spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/AbstractMqttMessageHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public String getComponentType() {
281281
}
282282

283283
protected void incrementClientInstance() {
284-
this.clientInstance++; //NOSONAR - false positive - called from synchronized block
284+
this.clientInstance++;
285285
}
286286

287287
/**
@@ -291,7 +291,7 @@ protected void incrementClientInstance() {
291291
* @since 4.1
292292
*/
293293
public void setCompletionTimeout(long completionTimeout) {
294-
this.completionTimeout = completionTimeout; // NOSONAR (sync)
294+
this.completionTimeout = completionTimeout;
295295
}
296296

297297
protected long getCompletionTimeout() {
@@ -305,7 +305,7 @@ protected long getCompletionTimeout() {
305305
* @since 5.1.10
306306
*/
307307
public void setDisconnectCompletionTimeout(long completionTimeout) {
308-
this.disconnectCompletionTimeout = completionTimeout; // NOSONAR (sync)
308+
this.disconnectCompletionTimeout = completionTimeout;
309309
}
310310

311311
protected long getDisconnectCompletionTimeout() {

0 commit comments

Comments
 (0)