Reinstate warns for publish events from Initiator

JIRA: https://jira.spring.io/browse/INT-4220,
https://jira.spring.io/browse/INT-4246

* Stop one more internal `initiator` in the `LockRegistryLeaderInitiatorTests`
This commit is contained in:
Artem Bilan
2017-03-23 11:39:07 -04:00
parent fb7e4d6869
commit 752fe0356f
2 changed files with 17 additions and 7 deletions

View File

@@ -363,17 +363,27 @@ public class LockRegistryLeaderInitiator implements SmartLifecycle, DisposableBe
private void handleGranted() throws InterruptedException {
LockRegistryLeaderInitiator.this.candidate.onGranted(this.context);
if (LockRegistryLeaderInitiator.this.leaderEventPublisher != null) {
LockRegistryLeaderInitiator.this.leaderEventPublisher.publishOnGranted(
LockRegistryLeaderInitiator.this, this.context, this.lockKey);
try {
LockRegistryLeaderInitiator.this.leaderEventPublisher.publishOnGranted(
LockRegistryLeaderInitiator.this, this.context, this.lockKey);
}
catch (Exception e) {
logger.warn("Error publishing OnGranted event.", e);
}
}
}
private void handleRevoked() {
LockRegistryLeaderInitiator.this.candidate.onRevoked(this.context);
if (LockRegistryLeaderInitiator.this.leaderEventPublisher != null) {
LockRegistryLeaderInitiator.this.leaderEventPublisher.publishOnRevoked(
LockRegistryLeaderInitiator.this, this.context,
LockRegistryLeaderInitiator.this.candidate.getRole());
try {
LockRegistryLeaderInitiator.this.leaderEventPublisher.publishOnRevoked(
LockRegistryLeaderInitiator.this, this.context,
LockRegistryLeaderInitiator.this.candidate.getRole());
}
catch (Exception e) {
logger.warn("Error publishing OnRevoked event.", e);
}
}
}

View File

@@ -17,7 +17,6 @@
package org.springframework.integration.support.leader;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -104,6 +103,7 @@ public class LockRegistryLeaderInitiatorTests {
this.initiator.stop();
assertThat(other.await(20, TimeUnit.SECONDS), is(true));
assertThat(another.getContext().isLeader(), is(true));
another.stop();
}
@Test
@@ -129,7 +129,7 @@ public class LockRegistryLeaderInitiatorTests {
initiator.start();
assertTrue(onGranted.await(10, TimeUnit.SECONDS));
assertFalse(initiator.getContext().isLeader());
assertTrue(initiator.getContext().isLeader());
initiator.stop();
}