Throwables { public static boolean containsNonRecoverable(@Nonnull final Throwable t) { return contains(t, nonRecoverableClassificationPredicate); } private  Throwables(); static boolean isRetryable(final Throwable value); static Predicate<Throwable> getIsRetryablePredicate(); static void setIsRetryablePredicate(final Predicate<Throwable> isRetryablePredicate); static int getNrSuppressedExceptions(final Throwable t); static int getNrRecursiveSuppressedExceptions(final Throwable t); @Nullable static Throwable removeOldestSuppressedRecursive(final Throwable t); @Nullable static Throwable removeOldestSuppressed(final Throwable t); @CheckReturnValue @Deprecated static T suppress(@Nonnull final T t, @Nonnull final Throwable suppressed); static void suppressLimited(@Nonnull final Throwable t, @Nonnull final Throwable suppressed); @SuppressFBWarnings("NOS_NON_OWNED_SYNCHRONIZATION") static void suppressLimited(@Nonnull final Throwable t, @Nonnull final Throwable suppressed,
          final int maxSuppressed); @CheckReturnValue static T suppress(@Nonnull final T t, @Nonnull final Throwable suppressed,
          final int maxSuppressed); static Throwable[] getSuppressed(final Throwable t); static void writeTo(final StackTraceElement element, @Nullable final StackTraceElement previous,
          final Appendable to, final PackageDetail detail,
          final boolean abbreviatedTraceElement); static String toString(final Throwable t); static String toString(final Throwable t, final PackageDetail detail); static String toString(final Throwable t, final PackageDetail detail, final boolean abbreviatedTraceElement); static StringBuilder toStringBuilder(final Throwable t, final PackageDetail detail); static StringBuilder toStringBuilder(final Throwable t, final PackageDetail detail,
          final boolean abbreviatedTraceElement); static void writeTo(@Nonnull final Throwable t, @Nonnull final PrintStream to,
          @Nonnull final PackageDetail detail); @SuppressFBWarnings({"OCP_OVERLY_CONCRETE_PARAMETER"}) // on purpose :-) static void writeTo(@Nonnull final Throwable t, @Nonnull final PrintStream to,
          @Nonnull final PackageDetail detail, final boolean abbreviatedTraceElement); static void writeTo(final Throwable t, final Appendable to, final PackageDetail detail); static void writeTo(final Throwable t, final Appendable to, final PackageDetail detail,
          final String prefix); static void writeTo(final Throwable t, final Appendable to, final PackageDetail detail,
          final boolean abbreviatedTraceElement); static void writeTo(final Throwable t, final Appendable to, final PackageDetail detail,
          final boolean abbreviatedTraceElement, final String prefix); static void writeThrowableDetail(final Throwable t, final Appendable to, final PackageDetail detail,
          final boolean abbreviatedTraceElement, final String prefix); static void writeMessageString(final Appendable to, final Throwable t); static void writeTo(final StackTraceElement[] trace, final Appendable to, final PackageDetail detail,
          final boolean abbreviatedTraceElement); static void writeTo(final StackTraceElement[] trace, final Appendable to, final PackageDetail detail,
          final boolean abbreviatedTraceElement, final String prefix); static int commonFrames(final StackTraceElement[] trace, final StackTraceElement[] enclosingTrace); static boolean isNonRecoverable(@Nonnull final Throwable t); static boolean containsNonRecoverable(@Nonnull final Throwable t); static boolean contains(@Nonnull final Throwable t, final Predicate<Throwable> predicate); static boolean contains(@Nonnull final Throwable t, @Nonnull final Throwable toLookFor); @Nullable @CheckReturnValue static T first(@Nonnull final Throwable t, final Class<T> clasz); @Nullable @CheckReturnValue static Throwable first(@Nonnull final Throwable t, final Predicate<Throwable> predicate); @Nullable @CheckReturnValue static Throwable firstCause(@Nonnull final Throwable throwable, final Predicate<Throwable> predicate); static Predicate<Throwable> getNonRecoverablePredicate(); static void setNonRecoverablePredicate(final Predicate<Throwable> predicate); static void writeAbreviatedClassName(final String className, final Appendable writeTo); @SuppressFBWarnings("ITC_INHERITANCE_TYPE_CHECKING") static void throwException(final Exception ex); static final String SUPPRESSED_CAPTION; static final String CAUSE_CAPTION; }
@Test public void testRecoverable() { Throwable t = new RuntimeException(); Assert.assertFalse(Throwables.containsNonRecoverable(t)); t.addSuppressed(new IOException()); Assert.assertFalse(Throwables.containsNonRecoverable(t)); t.addSuppressed(new OutOfMemoryError()); Assert.assertTrue(Throwables.containsNonRecoverable(t)); t = new RuntimeException(new RuntimeException(new IOException("Too many open files"))); Assert.assertTrue(Throwables.containsNonRecoverable(t)); t = new RuntimeException(new RuntimeException(new StackOverflowError())); Assert.assertFalse(Throwables.containsNonRecoverable(t)); }