@@ -93,11 +93,11 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat
93
93
94
94
@ Override
95
95
public void setApplicationContext (ApplicationContext applicationContext ) throws BeansException {
96
- this .applicationContext = applicationContext ; // NOSONAR (sync)
96
+ this .applicationContext = applicationContext ;
97
97
}
98
98
99
- protected @ Nullable ApplicationContext getApplicationContext () {
100
- return this .applicationContext ; // NOSONAR (sync)
99
+ protected ApplicationContext getApplicationContext () {
100
+ return this .applicationContext ;
101
101
}
102
102
103
103
/**
@@ -107,7 +107,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
107
107
* @param applicationName the application name.
108
108
*/
109
109
public void setApplicationName (String applicationName ) {
110
- this .applicationName = applicationName ; //NOSONAR (sync)
110
+ this .applicationName = applicationName ;
111
111
}
112
112
113
113
/**
@@ -136,19 +136,20 @@ public void onApplicationEvent(ContextRefreshedEvent event) {
136
136
* @see #rebuild()
137
137
*/
138
138
public Graph getGraph () {
139
- if (this .graph == null ) {
139
+ var localGraph = this .graph ;
140
+ if (localGraph == null ) {
140
141
this .lock .lock ();
141
142
try {
142
- if (this .graph == null ) {
143
- this .graph = buildGraph ();
143
+ localGraph = this .graph ;
144
+ if (localGraph == null ) {
145
+ localGraph = buildGraph ();
144
146
}
145
147
}
146
148
finally {
147
149
this .lock .unlock ();
148
150
}
149
151
}
150
- var graph = this .graph ;
151
- return graph ;
152
+ return localGraph ;
152
153
}
153
154
154
155
/**
@@ -216,9 +217,9 @@ private Graph buildGraph() {
216
217
gateways (nodes , links , channelNodes );
217
218
producers (nodes , links , channelNodes );
218
219
consumers (nodes , links , channelNodes );
219
- var graph = new Graph (descriptor , nodes , links );
220
- this .graph = graph ;
221
- return graph ;
220
+ var localGraph = new Graph (descriptor , nodes , links );
221
+ this .graph = localGraph ;
222
+ return localGraph ;
222
223
}
223
224
224
225
private Map <String , MessageChannelNode > channels (Collection <IntegrationNode > nodes ) {
@@ -228,8 +229,8 @@ private Map<String, MessageChannelNode> channels(Collection<IntegrationNode> nod
228
229
.map (e -> {
229
230
MessageChannel messageChannel = e .getValue ();
230
231
MessageChannelNode messageChannelNode = this .nodeFactory .channelNode (e .getKey (), messageChannel );
231
- if (messageChannel instanceof NamedComponent ) {
232
- messageChannelNode .addProperties (getAdditionalPropertiesIfAny (( NamedComponent ) messageChannel ));
232
+ if (messageChannel instanceof NamedComponent namedComponent ) {
233
+ messageChannelNode .addProperties (getAdditionalPropertiesIfAny (namedComponent ));
233
234
}
234
235
return messageChannelNode ;
235
236
})
@@ -323,8 +324,8 @@ private void consumers(Collection<IntegrationNode> nodes, Collection<LinkNode> l
323
324
.map (e -> {
324
325
IntegrationConsumer consumer = e .getValue ();
325
326
MessageHandlerNode handlerNode =
326
- consumer instanceof PollingConsumer
327
- ? this .nodeFactory .polledHandlerNode (e .getKey (), ( PollingConsumer ) consumer )
327
+ consumer instanceof PollingConsumer pollingConsumer
328
+ ? this .nodeFactory .polledHandlerNode (e .getKey (), pollingConsumer )
328
329
: this .nodeFactory .handlerNode (e .getKey (), consumer );
329
330
handlerNode .addProperties (getAdditionalPropertiesIfAny (consumer ));
330
331
return handlerNode ;
@@ -357,20 +358,20 @@ private void producerLink(Collection<LinkNode> links, Map<String, MessageChannel
357
358
if (channelNode != null ) {
358
359
links .add (new LinkNode (endpointNode .getNodeId (), channelNode .getNodeId (), LinkNode .Type .output ));
359
360
}
360
- if (endpointNode instanceof ErrorCapableNode ) {
361
- channelNode = channelNodes .get ((( ErrorCapableNode ) endpointNode ) .getErrors ());
361
+ if (endpointNode instanceof ErrorCapableNode errorCapableNode ) {
362
+ channelNode = channelNodes .get (errorCapableNode .getErrors ());
362
363
if (channelNode != null ) {
363
364
links .add (new LinkNode (endpointNode .getNodeId (), channelNode .getNodeId (), LinkNode .Type .error ));
364
365
}
365
366
}
366
- if (endpointNode instanceof DiscardingMessageHandlerNode ) {
367
- channelNode = channelNodes .get ((( DiscardingMessageHandlerNode ) endpointNode ) .getDiscards ());
367
+ if (endpointNode instanceof DiscardingMessageHandlerNode discardingMessageHandlerNode ) {
368
+ channelNode = channelNodes .get (discardingMessageHandlerNode .getDiscards ());
368
369
if (channelNode != null ) {
369
370
links .add (new LinkNode (endpointNode .getNodeId (), channelNode .getNodeId (), LinkNode .Type .discard ));
370
371
}
371
372
}
372
- if (endpointNode instanceof RoutingMessageHandlerNode ) {
373
- Collection <String > routes = (( RoutingMessageHandlerNode ) endpointNode ) .getRoutes ();
373
+ if (endpointNode instanceof RoutingMessageHandlerNode routingMessageHandlerNode ) {
374
+ Collection <String > routes = routingMessageHandlerNode .getRoutes ();
374
375
for (String route : routes ) {
375
376
channelNode = channelNodes .get (route );
376
377
if (channelNode != null ) {
@@ -412,13 +413,6 @@ MessageGatewayNode gatewayNode(String name, MessagingGatewaySupport gateway) {
412
413
return new MessageGatewayNode (this .nodeId .incrementAndGet (), name , gateway , requestChannel , errorChannel );
413
414
}
414
415
415
- @ Contract ("null -> null; !null -> !null" )
416
- private @ Nullable String channelToBeanName (@ Nullable MessageChannel messageChannel ) {
417
- return messageChannel instanceof NamedComponent namedComponent
418
- ? namedComponent .getBeanName ()
419
- : Objects .toString (messageChannel , null );
420
- }
421
-
422
416
MessageProducerNode producerNode (String name , MessageProducerSupport producer ) {
423
417
String errorChannel = channelToBeanName (producer .getErrorChannel ());
424
418
String outputChannel = channelToBeanName (producer .getOutputChannel ());
@@ -554,18 +548,19 @@ MessageHandlerNode routingHandler(String name, IntegrationConsumer consumer, Mes
554
548
}
555
549
556
550
MessageHandlerNode recipientListRoutingHandler (String name , IntegrationConsumer consumer ,
557
- MessageHandler handler , RecipientListRouterManagement router , @ Nullable String output , @ Nullable String errors ,
558
- boolean polled ) {
551
+ MessageHandler handler , RecipientListRouterManagement router , @ Nullable String output ,
552
+ @ Nullable String errors , boolean polled ) {
559
553
560
554
List <String > routes =
561
555
router .getRecipients ()
562
556
.stream ()
563
557
.map (recipient -> {
564
558
var messageChannel = channelToBeanName (((Recipient ) recipient ).getChannel ());
565
- Assert .state (messageChannel != null , "messageChannel must not be null for " + recipient );
559
+ Assert .state (messageChannel != null ,
560
+ "messageChannel must not be null for " + recipient );
566
561
return messageChannel ;
567
562
})
568
- .collect ( Collectors . toList () );
563
+ .toList ();
569
564
570
565
String inputChannel = channelToBeanName (consumer .getInputChannel ());
571
566
return polled
@@ -579,6 +574,13 @@ void reset() {
579
574
this .nodeId .set (0 );
580
575
}
581
576
577
+ @ Contract ("null -> null; !null -> !null" )
578
+ private static @ Nullable String channelToBeanName (@ Nullable MessageChannel messageChannel ) {
579
+ return messageChannel instanceof NamedComponent namedComponent
580
+ ? namedComponent .getBeanName ()
581
+ : Objects .toString (messageChannel , null );
582
+ }
583
+
582
584
}
583
585
584
586
}
0 commit comments