google-nomulus/javatests/google/registry/util
guyben 552940a816 Remove the reduntant 'afterFinalFailure' from Retrier
'afterFinalFailure' is called just before rethrowing a non-retrying error from
the retrier. This can happen either because the exception shouldn't be retried,
or because we exceeded the maximum number of retries.

The same thing can be done by catching that thrown error outside of the
retrier:

retrier.callWithRetry(
  callable,
  new FailureReporter() {
    @Override
    void afterFinalFailure(Throwable thrown, int failures) {
      // do something with thrown
    }
  },
  RetriableException.class);

is (almost) the same as:

try {
  retrier.callWithRetry(callable, RetriableException.class);
} catch (Throwable thrown) {
  // do something with thrown
  throw thrown;
}

("almost" because the retrier might wrap the Throwable in a RuntimeException,
so you might need to getCause or getRootCause. Also - there is the
"beforeRetry" I ignored for the example)

Removing "afterFinalFailure" also makes the FailureReporter in line with Java 8
functional interface - meaning we can more easily create it when we do need to
override "beforeRetry".

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=189972101
2018-04-02 16:26:19 -04:00
..
BUILD Switch from Guava Optionals to Java 8 Optionals 2017-10-24 16:53:47 -04:00
CidrAddressBlockTest.java Refactor Guava functional methods to use lambdas 2017-12-01 22:14:05 -05:00
CollectionUtilsTest.java Automatically refactor more exception testing to use new JUnit rules 2017-12-27 10:42:36 -05:00
ComparingInvocationHandlerTest.java Clean up some code quality issues 2017-12-01 22:14:06 -05:00
ConcurrentTest.java Merge JUnitBackport's expectThrows into assertThrows 2018-03-06 18:56:15 -05:00
DateTimeUtilsTest.java Automatically refactor more exception testing to use new JUnit rules 2017-12-27 10:42:36 -05:00
DiffUtilsTest.java Remove unnecessary explicit generic type declarations 2017-11-07 17:11:29 -05:00
DomainNameUtilsTest.java Add sharded DNS publishing capability 2018-03-06 19:14:26 -05:00
HexDumperTest.java Automatically refactor more exception testing to use new JUnit rules 2017-12-27 10:42:36 -05:00
PosixTarHeaderSystemTest.java Remove implicit uses of platform default charset 2017-11-07 16:59:51 -05:00
PosixTarHeaderTest.java Merge JUnitBackport's expectThrows into assertThrows 2018-03-06 18:56:15 -05:00
RequestStatusCheckerImplTest.java Clean up some code quality issues 2017-12-01 22:14:06 -05:00
RetrierTest.java Remove the reduntant 'afterFinalFailure' from Retrier 2018-04-02 16:26:19 -04:00
SerializeUtilsTest.java Merge JUnitBackport's expectThrows into assertThrows 2018-03-06 18:56:15 -05:00
SqlTemplateTest.java Merge JUnitBackport's expectThrows into assertThrows 2018-03-06 18:56:15 -05:00
TaskEnqueuerTest.java Merge JUnitBackport's expectThrows into assertThrows 2018-03-06 18:56:15 -05:00
TeeOutputStreamTest.java Merge JUnitBackport's expectThrows into assertThrows 2018-03-06 18:56:15 -05:00
TypeUtilsTest.java Merge JUnitBackport's expectThrows into assertThrows 2018-03-06 18:56:15 -05:00
UrlFetchUtilsTest.java Merge JUnitBackport's expectThrows into assertThrows 2018-03-06 18:56:15 -05:00