Skip to content

Commit 19e8a65

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 7d5d996 commit 19e8a65

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-2019 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.
@@ -115,8 +115,8 @@ protected void onInit() {
115115
this.roleController.addLifecycleToRole(this.role, this);
116116
}
117117
catch (@SuppressWarnings("unused") NoSuchBeanDefinitionException e) {
118-
this.logger.trace("No LifecycleRoleController in the context");
119-
}
118+
this.logger.trace("No LifecycleRoleController in the context");
119+
}
120120
}
121121
}
122122

@@ -142,13 +142,7 @@ public final int getPhase() {
142142

143143
@Override
144144
public final boolean isRunning() {
145-
this.lifecycleLock.lock();
146-
try {
147-
return this.running;
148-
}
149-
finally {
150-
this.lifecycleLock.unlock();
151-
}
145+
return this.running;
152146
}
153147

154148
@Override

0 commit comments

Comments
 (0)