@Test @SuppressWarnings("checkstyle:IllegalCatch") public void testOnLeaderLocationChanged() { final LeaderLocationListener listener1 = mock(LeaderLocationListener.class); doThrow(new RuntimeException("Failed")).when(listener1).onLeaderLocationChanged(any()); final LeaderLocationListener listener2 = mock(LeaderLocationListener.class); doNothing().when(listener2).onLeaderLocationChanged(any()); final LeaderLocationListener listener3 = mock(LeaderLocationListener.class); doNothing().when(listener3).onLeaderLocationChanged(any()); final LeaderLocationListenerRegistration<?> reg1 = shardAccess.registerLeaderLocationListener(listener1); final LeaderLocationListenerRegistration<?> reg2 = shardAccess.registerLeaderLocationListener(listener2); final LeaderLocationListenerRegistration<?> reg3 = shardAccess.registerLeaderLocationListener(listener3); shardAccess.onLeaderLocationChanged(LeaderLocation.LOCAL); verify(listener1).onLeaderLocationChanged(eq(LeaderLocation.LOCAL)); verify(listener2).onLeaderLocationChanged(eq(LeaderLocation.LOCAL)); verify(listener3).onLeaderLocationChanged(eq(LeaderLocation.LOCAL)); reg1.close(); reg2.close(); shardAccess.onLeaderLocationChanged(LeaderLocation.REMOTE); verify(listener3).onLeaderLocationChanged(eq(LeaderLocation.REMOTE)); verifyNoMoreInteractions(listener1); verifyNoMoreInteractions(listener2); shardAccess.close(); shardAccess.onLeaderLocationChanged(LeaderLocation.UNKNOWN); verifyNoMoreInteractions(listener1); verifyNoMoreInteractions(listener2); verifyNoMoreInteractions(listener3); reg3.close(); }
@Override @SuppressWarnings("checkstyle:IllegalCatch") public void onLeaderLocationChanged(final LeaderLocation location) { if (closed) { return; } LOG.debug("Received leader location change notification. New leader location: {}", location); currentLeader = location; listeners.forEach(listener -> { try { listener.onLeaderLocationChanged(location); } catch (Exception e) { LOG.warn("Ignoring uncaught exception thrown be LeaderLocationListener {} " + "during processing leader location change {}", listener, location, e); } }); }
CDSShardAccessImpl implements CDSShardAccess, LeaderLocationListener, AutoCloseable { @Override @SuppressWarnings("checkstyle:IllegalCatch") public void onLeaderLocationChanged(final LeaderLocation location) { if (closed) { return; } LOG.debug("Received leader location change notification. New leader location: {}", location); currentLeader = location; listeners.forEach(listener -> { try { listener.onLeaderLocationChanged(location); } catch (Exception e) { LOG.warn("Ignoring uncaught exception thrown be LeaderLocationListener {} " + "during processing leader location change {}", listener, location, e); } }); } }
CDSShardAccessImpl implements CDSShardAccess, LeaderLocationListener, AutoCloseable { @Override @SuppressWarnings("checkstyle:IllegalCatch") public void onLeaderLocationChanged(final LeaderLocation location) { if (closed) { return; } LOG.debug("Received leader location change notification. New leader location: {}", location); currentLeader = location; listeners.forEach(listener -> { try { listener.onLeaderLocationChanged(location); } catch (Exception e) { LOG.warn("Ignoring uncaught exception thrown be LeaderLocationListener {} " + "during processing leader location change {}", listener, location, e); } }); } CDSShardAccessImpl(final DOMDataTreeIdentifier prefix, final ActorUtils actorUtils); }
CDSShardAccessImpl implements CDSShardAccess, LeaderLocationListener, AutoCloseable { @Override @SuppressWarnings("checkstyle:IllegalCatch") public void onLeaderLocationChanged(final LeaderLocation location) { if (closed) { return; } LOG.debug("Received leader location change notification. New leader location: {}", location); currentLeader = location; listeners.forEach(listener -> { try { listener.onLeaderLocationChanged(location); } catch (Exception e) { LOG.warn("Ignoring uncaught exception thrown be LeaderLocationListener {} " + "during processing leader location change {}", listener, location, e); } }); } CDSShardAccessImpl(final DOMDataTreeIdentifier prefix, final ActorUtils actorUtils); @Override DOMDataTreeIdentifier getShardIdentifier(); @Override LeaderLocation getLeaderLocation(); @Override CompletionStage<Void> makeLeaderLocal(); @Override LeaderLocationListenerRegistration<L> registerLeaderLocationListener(final L listener); @Override @SuppressWarnings("checkstyle:IllegalCatch") void onLeaderLocationChanged(final LeaderLocation location); @Override void close(); }
CDSShardAccessImpl implements CDSShardAccess, LeaderLocationListener, AutoCloseable { @Override @SuppressWarnings("checkstyle:IllegalCatch") public void onLeaderLocationChanged(final LeaderLocation location) { if (closed) { return; } LOG.debug("Received leader location change notification. New leader location: {}", location); currentLeader = location; listeners.forEach(listener -> { try { listener.onLeaderLocationChanged(location); } catch (Exception e) { LOG.warn("Ignoring uncaught exception thrown be LeaderLocationListener {} " + "during processing leader location change {}", listener, location, e); } }); } CDSShardAccessImpl(final DOMDataTreeIdentifier prefix, final ActorUtils actorUtils); @Override DOMDataTreeIdentifier getShardIdentifier(); @Override LeaderLocation getLeaderLocation(); @Override CompletionStage<Void> makeLeaderLocal(); @Override LeaderLocationListenerRegistration<L> registerLeaderLocationListener(final L listener); @Override @SuppressWarnings("checkstyle:IllegalCatch") void onLeaderLocationChanged(final LeaderLocation location); @Override void close();  }