PercentErrPerTimeFailureInterpreter implements FailureInterpreter { public boolean shouldTrip(Throwable cause) { if (isExceptionIgnorable(cause)) return false; if (hasWindowConditions()) { Long currentRequestCount = -1L; long numberOfErrorsAfter; synchronized (modificationLock) { errorTimes.add(System.currentTimeMillis()); requestCounts.add(requestCounter.sample()[0]); final long removeTimeBeforeMillis = System.currentTimeMillis() - windowMillis; final int numberOfErrorsBefore = this.errorTimes.size(); removeErrorsPriorToCutoffTime(numberOfErrorsBefore, removeTimeBeforeMillis); numberOfErrorsAfter = this.errorTimes.size(); currentRequestCount = this.requestCounts.get(requestCounts.size() - 1); } long windowRequests = (currentRequestCount - previousRequestHighWaterMark); return windowRequests >= requestThreshold && (((double) numberOfErrorsAfter / (double) windowRequests) * 100d >= percent); } return true; } @SuppressWarnings("unchecked")  PercentErrPerTimeFailureInterpreter(); @SuppressWarnings("unchecked")  PercentErrPerTimeFailureInterpreter(RequestCounter rc,
                                               int percent, long windowMillis); @SuppressWarnings("unchecked")  PercentErrPerTimeFailureInterpreter(PerformanceMonitor p,
                                               int percent, long windowMillis);  PercentErrPerTimeFailureInterpreter(Class<? extends Throwable>[] ignore);  PercentErrPerTimeFailureInterpreter(RequestCounter rc,
                                               Class<? extends Throwable>[] ignore,
                                               int percent, long windowMillis); boolean shouldTrip(Throwable cause); Set<Class<? extends Throwable>> getIgnore(); synchronized void setIgnore(Class<? extends Throwable>[] ignore); int getPercent(); void setPercent(int percent); long getWindowMillis(); void setWindowMillis(long windowMillis); void setRequestCounter(RequestCounter rc); void setRequestThreshold(int requestThreshold);  }
@Test public void testTripsWhenNoWindowConditionsExist() { PercentErrPerTimeFailureInterpreter pept = new PercentErrPerTimeFailureInterpreter(); assertTrue(pept.shouldTrip(new Exception())); }