@Override
    public void startLeaderElection(LeaderContender contender) throws Exception {
        synchronized (lock) {
            Preconditions.checkState(
                    leaderContender == null,
                    "No LeaderContender should have been registered with this LeaderElection, yet.");
            this.leaderContender = contender;

            this.leaderContender.grantLeadership(sessionID);
        }
    }
@Test
    void testRevokeCallOnClose() throws Exception {
        final AtomicBoolean revokeLeadershipCalled = new AtomicBoolean(false);
        final TestingGenericLeaderContender contender =
                TestingGenericLeaderContender.newBuilder()
                        .setRevokeLeadershipRunnable(() -> revokeLeadershipCalled.set(true))
                        .build();
        try (final LeaderElection testInstance = new StandaloneLeaderElection(SESSION_ID)) {
            testInstance.startLeaderElection(contender);
        }

        assertThat(revokeLeadershipCalled).isTrue();
    }