Skip to content

Commit d3ce5b5

Browse files
artembilangaryrussell
authored andcommitted
GH-3473: Fix dead lock around lifecycleLock
Fixes #3473 When `AbstractEndpoint.start()` and `AbstractEndpoint.isRunning()` are called from different thread on `synchronized` methods, we may end up with a dead lock: one thread waits for monitor on `synchronized` and another waits for the `lifecycleLock` * Change `AbstractEndpoint.isRunning()` to a plain `return this.running;` - there is no reason in a lock around returning this `volatile` property state **Cherry-pick to 5.4.x & 5.3.x**
1 parent 23e277d commit d3ce5b5

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractEndpoint.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -117,8 +117,8 @@ protected void onInit() {
117117
this.roleController.addLifecycleToRole(this.role, this);
118118
}
119119
catch (@SuppressWarnings("unused") NoSuchBeanDefinitionException e) {
120-
this.logger.trace("No LifecycleRoleController in the context");
121-
}
120+
this.logger.trace("No LifecycleRoleController in the context");
121+
}
122122
}
123123
}
124124

@@ -144,13 +144,7 @@ public final int getPhase() {
144144

145145
@Override
146146
public final boolean isRunning() {
147-
this.lifecycleLock.lock();
148-
try {
149-
return this.running;
150-
}
151-
finally {
152-
this.lifecycleLock.unlock();
153-
}
147+
return this.running;
154148
}
155149

156150
@Override

0 commit comments

Comments
 (0)