@Test public void shouldNotAllocateTimestampsIfAllocationFailuresDisallowsIt() { doThrow(RuntimeException.class).when(allocationFailures).verifyWeShouldIssueMoreTimestamps(); try { store.storeUpperLimit(1_000); } catch (Exception e) { } verify(delegate, never()).storeUpperLimit(anyLong()); }
@Override public synchronized void storeUpperLimit(long limit) { failures.verifyWeShouldIssueMoreTimestamps(); throwIfInterrupted(); try { delegate.storeUpperLimit(limit); } catch (Throwable t) { throw failures.responseTo(t); } }
ErrorCheckingTimestampBoundStore implements TimestampBoundStore { @Override public synchronized void storeUpperLimit(long limit) { failures.verifyWeShouldIssueMoreTimestamps(); throwIfInterrupted(); try { delegate.storeUpperLimit(limit); } catch (Throwable t) { throw failures.responseTo(t); } } }
ErrorCheckingTimestampBoundStore implements TimestampBoundStore { @Override public synchronized void storeUpperLimit(long limit) { failures.verifyWeShouldIssueMoreTimestamps(); throwIfInterrupted(); try { delegate.storeUpperLimit(limit); } catch (Throwable t) { throw failures.responseTo(t); } } ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate); @VisibleForTesting  ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate, TimestampAllocationFailures failures); }
ErrorCheckingTimestampBoundStore implements TimestampBoundStore { @Override public synchronized void storeUpperLimit(long limit) { failures.verifyWeShouldIssueMoreTimestamps(); throwIfInterrupted(); try { delegate.storeUpperLimit(limit); } catch (Throwable t) { throw failures.responseTo(t); } } ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate); @VisibleForTesting  ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate, TimestampAllocationFailures failures); @Override long getUpperLimit(); @Override synchronized void storeUpperLimit(long limit); }
ErrorCheckingTimestampBoundStore implements TimestampBoundStore { @Override public synchronized void storeUpperLimit(long limit) { failures.verifyWeShouldIssueMoreTimestamps(); throwIfInterrupted(); try { delegate.storeUpperLimit(limit); } catch (Throwable t) { throw failures.responseTo(t); } } ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate); @VisibleForTesting  ErrorCheckingTimestampBoundStore(TimestampBoundStore delegate, TimestampAllocationFailures failures); @Override long getUpperLimit(); @Override synchronized void storeUpperLimit(long limit);  }