henrik242 commented on code in PR #26028:
URL: https://github.com/apache/camel/pull/26028#discussion_r3916259695
##########
components/camel-master/src/main/java/org/apache/camel/component/master/MasterConsumer.java:
##########
@@ -225,30 +290,50 @@ private void onLeadershipLost() {
}
}
+ private boolean isStartPending() {
+ return leaderTaskFuture != null && !leaderTaskFuture.isDone();
+ }
+
+ private void cancelLeaderTask(boolean mayInterruptIfRunning) {
+ if (leaderTaskFuture != null) {
+ leaderTaskFuture.cancel(mayInterruptIfRunning);
+ leaderTaskFuture = null;
+ }
+ }
+
// **************************************
// Listener
// **************************************
private final class LeadershipListener implements
CamelClusterEventListener.Leadership {
@Override
public void leadershipChanged(CamelClusterView view,
CamelClusterMember leader) {
- if (!isRunAllowed()) {
- return;
- }
-
- if (view.getLocalMember().isLeader()) {
- try {
- onLeadershipTaken();
- } catch (Exception e) {
- getExceptionHandler().handleException("Error starting
consumer while taking leadership", e);
+ lock.lock();
Review Comment:
unlocked isRunAllowed() fast path restored, start moved off the lock, doStop
cancels before removing the listener; residual is pre-existing and documented,
follow-up JIRA.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]