@Override
    public LeaderElection createLeaderElection(String componentId) {
        synchronized (lock) {
            Preconditions.checkState(
                    !leadershipOperationExecutor.isShutdown(),
                    "The service was already closed and cannot be reused.");
            Preconditions.checkState(
                    !leaderContenderRegistry.containsKey(componentId),
                    "There shouldn't be any contender registered under the passed component '%s'.",
                    componentId);
            return new DefaultLeaderElection(this, componentId);
        }
    }
@Test
    void testMultipleDriverCreations() throws Exception {
        final AtomicInteger closeCount = new AtomicInteger(0);
        final TestingLeaderElectionDriver.Factory driverFactory =
                new TestingLeaderElectionDriver.Factory(
                        TestingLeaderElectionDriver.newNoOpBuilder()
                                .setCloseConsumer(ignoredLock -> closeCount.incrementAndGet()));

        try (final DefaultLeaderElectionService testInstance =
                new DefaultLeaderElectionService(driverFactory)) {

            final String componentId = "component_id";
            final int numberOfStartCloseSessions = 2;
            for (int i = 1; i <= numberOfStartCloseSessions; i++) {
                assertThat(driverFactory.getCreatedDriverCount()).isEqualTo(i - 1);
                assertThat(closeCount).hasValue(i - 1);

                try (final LeaderElection leaderElection =
                        testInstance.createLeaderElection(componentId)) {
                    leaderElection.startLeaderElection(
                            TestingGenericLeaderContender.newBuilder().build());
                }

                assertThat(driverFactory.getCreatedDriverCount()).isEqualTo(i);
                assertThat(closeCount).hasValue(i);
            }
        }
    }