@@ -93,11 +93,11 @@ public class IntegrationGraphServer implements ApplicationContextAware, Applicat
9393
9494 @ Override
9595 public void setApplicationContext (ApplicationContext applicationContext ) throws BeansException {
96- this .applicationContext = applicationContext ; // NOSONAR (sync)
96+ this .applicationContext = applicationContext ;
9797 }
9898
99- protected @ Nullable ApplicationContext getApplicationContext () {
100- return this .applicationContext ; // NOSONAR (sync)
99+ protected ApplicationContext getApplicationContext () {
100+ return this .applicationContext ;
101101 }
102102
103103 /**
@@ -107,7 +107,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
107107 * @param applicationName the application name.
108108 */
109109 public void setApplicationName (String applicationName ) {
110- this .applicationName = applicationName ; //NOSONAR (sync)
110+ this .applicationName = applicationName ;
111111 }
112112
113113 /**
@@ -136,19 +136,20 @@ public void onApplicationEvent(ContextRefreshedEvent event) {
136136 * @see #rebuild()
137137 */
138138 public Graph getGraph () {
139- if (this .graph == null ) {
139+ var localGraph = this .graph ;
140+ if (localGraph == null ) {
140141 this .lock .lock ();
141142 try {
142- if (this .graph == null ) {
143- this .graph = buildGraph ();
143+ localGraph = this .graph ;
144+ if (localGraph == null ) {
145+ localGraph = buildGraph ();
144146 }
145147 }
146148 finally {
147149 this .lock .unlock ();
148150 }
149151 }
150- var graph = this .graph ;
151- return graph ;
152+ return localGraph ;
152153 }
153154
154155 /**
@@ -216,9 +217,9 @@ private Graph buildGraph() {
216217 gateways (nodes , links , channelNodes );
217218 producers (nodes , links , channelNodes );
218219 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 ;
222223 }
223224
224225 private Map <String , MessageChannelNode > channels (Collection <IntegrationNode > nodes ) {
@@ -228,8 +229,8 @@ private Map<String, MessageChannelNode> channels(Collection<IntegrationNode> nod
228229 .map (e -> {
229230 MessageChannel messageChannel = e .getValue ();
230231 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 ));
233234 }
234235 return messageChannelNode ;
235236 })
@@ -323,8 +324,8 @@ private void consumers(Collection<IntegrationNode> nodes, Collection<LinkNode> l
323324 .map (e -> {
324325 IntegrationConsumer consumer = e .getValue ();
325326 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 )
328329 : this .nodeFactory .handlerNode (e .getKey (), consumer );
329330 handlerNode .addProperties (getAdditionalPropertiesIfAny (consumer ));
330331 return handlerNode ;
@@ -357,20 +358,20 @@ private void producerLink(Collection<LinkNode> links, Map<String, MessageChannel
357358 if (channelNode != null ) {
358359 links .add (new LinkNode (endpointNode .getNodeId (), channelNode .getNodeId (), LinkNode .Type .output ));
359360 }
360- if (endpointNode instanceof ErrorCapableNode ) {
361- channelNode = channelNodes .get ((( ErrorCapableNode ) endpointNode ) .getErrors ());
361+ if (endpointNode instanceof ErrorCapableNode errorCapableNode ) {
362+ channelNode = channelNodes .get (errorCapableNode .getErrors ());
362363 if (channelNode != null ) {
363364 links .add (new LinkNode (endpointNode .getNodeId (), channelNode .getNodeId (), LinkNode .Type .error ));
364365 }
365366 }
366- if (endpointNode instanceof DiscardingMessageHandlerNode ) {
367- channelNode = channelNodes .get ((( DiscardingMessageHandlerNode ) endpointNode ) .getDiscards ());
367+ if (endpointNode instanceof DiscardingMessageHandlerNode discardingMessageHandlerNode ) {
368+ channelNode = channelNodes .get (discardingMessageHandlerNode .getDiscards ());
368369 if (channelNode != null ) {
369370 links .add (new LinkNode (endpointNode .getNodeId (), channelNode .getNodeId (), LinkNode .Type .discard ));
370371 }
371372 }
372- if (endpointNode instanceof RoutingMessageHandlerNode ) {
373- Collection <String > routes = (( RoutingMessageHandlerNode ) endpointNode ) .getRoutes ();
373+ if (endpointNode instanceof RoutingMessageHandlerNode routingMessageHandlerNode ) {
374+ Collection <String > routes = routingMessageHandlerNode .getRoutes ();
374375 for (String route : routes ) {
375376 channelNode = channelNodes .get (route );
376377 if (channelNode != null ) {
@@ -412,13 +413,6 @@ MessageGatewayNode gatewayNode(String name, MessagingGatewaySupport gateway) {
412413 return new MessageGatewayNode (this .nodeId .incrementAndGet (), name , gateway , requestChannel , errorChannel );
413414 }
414415
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-
422416 MessageProducerNode producerNode (String name , MessageProducerSupport producer ) {
423417 String errorChannel = channelToBeanName (producer .getErrorChannel ());
424418 String outputChannel = channelToBeanName (producer .getOutputChannel ());
@@ -554,18 +548,19 @@ MessageHandlerNode routingHandler(String name, IntegrationConsumer consumer, Mes
554548 }
555549
556550 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 ) {
559553
560554 List <String > routes =
561555 router .getRecipients ()
562556 .stream ()
563557 .map (recipient -> {
564558 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 );
566561 return messageChannel ;
567562 })
568- .collect ( Collectors . toList () );
563+ .toList ();
569564
570565 String inputChannel = channelToBeanName (consumer .getInputChannel ());
571566 return polled
@@ -579,6 +574,13 @@ void reset() {
579574 this .nodeId .set (0 );
580575 }
581576
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+
582584 }
583585
584586}
0 commit comments