@@ -121,7 +121,7 @@ public void setAdditionalPropertiesCallback(@Nullable Function<NamedComponent,
121
121
@ Override
122
122
public void onApplicationEvent (ContextRefreshedEvent event ) {
123
123
if (event .getApplicationContext ().equals (this .applicationContext )) {
124
- buildGraph ();
124
+ rebuild ();
125
125
}
126
126
}
127
127
@@ -132,7 +132,7 @@ public void onApplicationEvent(ContextRefreshedEvent event) {
132
132
* @see #rebuild()
133
133
*/
134
134
public Graph getGraph () {
135
- if (this .graph == null ) { // NOSONAR (sync)
135
+ if (this .graph == null ) {
136
136
this .lock .lock ();
137
137
try {
138
138
if (this .graph == null ) {
@@ -153,7 +153,13 @@ public Graph getGraph() {
153
153
* @see #getGraph()
154
154
*/
155
155
public Graph rebuild () {
156
- return buildGraph ();
156
+ this .lock .lock ();
157
+ try {
158
+ return buildGraph ();
159
+ }
160
+ finally {
161
+ this .lock .unlock ();
162
+ }
157
163
}
158
164
159
165
/**
@@ -170,7 +176,7 @@ protected <T> Map<String, T> getBeansOfType(Class<T> type) {
170
176
}
171
177
172
178
private <T extends IntegrationNode > T enhance (T node ) {
173
- if (this .micrometerEnhancer != null ) { // NOSONAR - synchronized inconsistency
179
+ if (this .micrometerEnhancer != null ) {
174
180
return this .micrometerEnhancer .enhance (node );
175
181
}
176
182
else {
@@ -179,40 +185,34 @@ private <T extends IntegrationNode> T enhance(T node) {
179
185
}
180
186
181
187
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 );
212
190
}
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" );
215
202
}
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 ;
216
216
}
217
217
218
218
private Map <String , MessageChannelNode > channels (Collection <IntegrationNode > nodes ) {
0 commit comments