@Test public void tooManySuppressedExceptions() { try { CompletionExceptionLogHelper.forceSetMaxSuppressedCountForTesting(2); final Exception base = createRuntimeException(); Exception e0 = createCompletionException(base); Exception e1 = createCompletionException(base); assertEquals(base, FDBExceptions.wrapException(e0)); assertEquals(base, FDBExceptions.wrapException(e1)); Throwable[] suppressedExceptions = base.getSuppressed(); assertEquals(2, suppressedExceptions.length); assertThat(Arrays.asList(suppressedExceptions), contains(e0, e1)); Exception e2 = createCompletionException(base); assertEquals(base, FDBExceptions.wrapException(e2)); suppressedExceptions = base.getSuppressed(); assertEquals(3, suppressedExceptions.length); assertThat(Arrays.asList(suppressedExceptions), hasItems(e0, e1)); assertThat(Arrays.asList(suppressedExceptions), not(hasItem(e2))); Throwable countException = suppressedExceptions[2]; assertThat(countException, instanceOf(CompletionExceptionLogHelper.IgnoredSuppressedExceptionCount.class)); assertEquals(1, ((CompletionExceptionLogHelper.IgnoredSuppressedExceptionCount)countException).getCount()); Exception e3 = createCompletionException(base); assertEquals(base, FDBExceptions.wrapException(e3)); suppressedExceptions = base.getSuppressed(); assertEquals(3, suppressedExceptions.length); assertThat(Arrays.asList(suppressedExceptions), hasItems(e0, e1)); assertThat(Arrays.asList(suppressedExceptions), not(anyOf(Matchers.<Throwable>hasItem(e2), hasItem(e3)))); countException = suppressedExceptions[2]; assertThat(countException, instanceOf(CompletionExceptionLogHelper.IgnoredSuppressedExceptionCount.class)); assertEquals(2, ((CompletionExceptionLogHelper.IgnoredSuppressedExceptionCount)countException).getCount()); } finally { CompletionExceptionLogHelper.forceSetMaxSuppressedCountForTesting(Integer.MAX_VALUE); } }
public static RuntimeException wrapException(@Nonnull Throwable ex) { Object[] logInfo; if (ex instanceof LoggableKeysAndValues) { logInfo = ((LoggableKeysAndValues)ex).exportLogInfo(); } else { logInfo = EMPTY_KEYS_AND_VALUES; } if (ex instanceof CompletionException) { ex = CompletionExceptionLogHelper.asCause((CompletionException)ex); } else if (ex instanceof ExecutionException) { ex = CompletionExceptionLogHelper.asCause((ExecutionException)ex); } if (ex instanceof FDBException) { FDBException fdbex = (FDBException)ex; switch (fdbex.getCode()) { case 1007: return new FDBStoreTransactionIsTooOldException(fdbex).addLogInfo(logInfo); case 1020: return new FDBStoreTransactionConflictException(fdbex).addLogInfo(logInfo); case 1031: return new FDBStoreTransactionTimeoutException(fdbex).addLogInfo(logInfo); case 2101: return new FDBStoreTransactionSizeException(fdbex).addLogInfo(logInfo); case 2102: return new FDBStoreKeySizeException(fdbex).addLogInfo(logInfo); case 2103: return new FDBStoreValueSizeException(fdbex).addLogInfo(logInfo); default: if (fdbex.isRetryable()) { return new FDBStoreRetriableException(fdbex).addLogInfo(logInfo); } else { return new FDBStoreException(fdbex).addLogInfo(logInfo); } } } if (ex instanceof RuntimeException) { return (RuntimeException)ex; } if (ex instanceof InterruptedException) { return new RecordCoreInterruptedException(ex.getMessage(), ex).addLogInfo(logInfo); } return new RecordCoreException(ex.getMessage(), ex).addLogInfo(logInfo); }
FDBExceptions { public static RuntimeException wrapException(@Nonnull Throwable ex) { Object[] logInfo; if (ex instanceof LoggableKeysAndValues) { logInfo = ((LoggableKeysAndValues)ex).exportLogInfo(); } else { logInfo = EMPTY_KEYS_AND_VALUES; } if (ex instanceof CompletionException) { ex = CompletionExceptionLogHelper.asCause((CompletionException)ex); } else if (ex instanceof ExecutionException) { ex = CompletionExceptionLogHelper.asCause((ExecutionException)ex); } if (ex instanceof FDBException) { FDBException fdbex = (FDBException)ex; switch (fdbex.getCode()) { case 1007: return new FDBStoreTransactionIsTooOldException(fdbex).addLogInfo(logInfo); case 1020: return new FDBStoreTransactionConflictException(fdbex).addLogInfo(logInfo); case 1031: return new FDBStoreTransactionTimeoutException(fdbex).addLogInfo(logInfo); case 2101: return new FDBStoreTransactionSizeException(fdbex).addLogInfo(logInfo); case 2102: return new FDBStoreKeySizeException(fdbex).addLogInfo(logInfo); case 2103: return new FDBStoreValueSizeException(fdbex).addLogInfo(logInfo); default: if (fdbex.isRetryable()) { return new FDBStoreRetriableException(fdbex).addLogInfo(logInfo); } else { return new FDBStoreException(fdbex).addLogInfo(logInfo); } } } if (ex instanceof RuntimeException) { return (RuntimeException)ex; } if (ex instanceof InterruptedException) { return new RecordCoreInterruptedException(ex.getMessage(), ex).addLogInfo(logInfo); } return new RecordCoreException(ex.getMessage(), ex).addLogInfo(logInfo); } }
FDBExceptions { public static RuntimeException wrapException(@Nonnull Throwable ex) { Object[] logInfo; if (ex instanceof LoggableKeysAndValues) { logInfo = ((LoggableKeysAndValues)ex).exportLogInfo(); } else { logInfo = EMPTY_KEYS_AND_VALUES; } if (ex instanceof CompletionException) { ex = CompletionExceptionLogHelper.asCause((CompletionException)ex); } else if (ex instanceof ExecutionException) { ex = CompletionExceptionLogHelper.asCause((ExecutionException)ex); } if (ex instanceof FDBException) { FDBException fdbex = (FDBException)ex; switch (fdbex.getCode()) { case 1007: return new FDBStoreTransactionIsTooOldException(fdbex).addLogInfo(logInfo); case 1020: return new FDBStoreTransactionConflictException(fdbex).addLogInfo(logInfo); case 1031: return new FDBStoreTransactionTimeoutException(fdbex).addLogInfo(logInfo); case 2101: return new FDBStoreTransactionSizeException(fdbex).addLogInfo(logInfo); case 2102: return new FDBStoreKeySizeException(fdbex).addLogInfo(logInfo); case 2103: return new FDBStoreValueSizeException(fdbex).addLogInfo(logInfo); default: if (fdbex.isRetryable()) { return new FDBStoreRetriableException(fdbex).addLogInfo(logInfo); } else { return new FDBStoreException(fdbex).addLogInfo(logInfo); } } } if (ex instanceof RuntimeException) { return (RuntimeException)ex; } if (ex instanceof InterruptedException) { return new RecordCoreInterruptedException(ex.getMessage(), ex).addLogInfo(logInfo); } return new RecordCoreException(ex.getMessage(), ex).addLogInfo(logInfo); } private  FDBExceptions(); }
FDBExceptions { public static RuntimeException wrapException(@Nonnull Throwable ex) { Object[] logInfo; if (ex instanceof LoggableKeysAndValues) { logInfo = ((LoggableKeysAndValues)ex).exportLogInfo(); } else { logInfo = EMPTY_KEYS_AND_VALUES; } if (ex instanceof CompletionException) { ex = CompletionExceptionLogHelper.asCause((CompletionException)ex); } else if (ex instanceof ExecutionException) { ex = CompletionExceptionLogHelper.asCause((ExecutionException)ex); } if (ex instanceof FDBException) { FDBException fdbex = (FDBException)ex; switch (fdbex.getCode()) { case 1007: return new FDBStoreTransactionIsTooOldException(fdbex).addLogInfo(logInfo); case 1020: return new FDBStoreTransactionConflictException(fdbex).addLogInfo(logInfo); case 1031: return new FDBStoreTransactionTimeoutException(fdbex).addLogInfo(logInfo); case 2101: return new FDBStoreTransactionSizeException(fdbex).addLogInfo(logInfo); case 2102: return new FDBStoreKeySizeException(fdbex).addLogInfo(logInfo); case 2103: return new FDBStoreValueSizeException(fdbex).addLogInfo(logInfo); default: if (fdbex.isRetryable()) { return new FDBStoreRetriableException(fdbex).addLogInfo(logInfo); } else { return new FDBStoreException(fdbex).addLogInfo(logInfo); } } } if (ex instanceof RuntimeException) { return (RuntimeException)ex; } if (ex instanceof InterruptedException) { return new RecordCoreInterruptedException(ex.getMessage(), ex).addLogInfo(logInfo); } return new RecordCoreException(ex.getMessage(), ex).addLogInfo(logInfo); } private  FDBExceptions(); static RuntimeException wrapException(@Nonnull Throwable ex); static boolean isRetriable(@Nullable Throwable ex); @Nullable static FDBException getFDBCause(@Nullable Throwable ex); }
FDBExceptions { public static RuntimeException wrapException(@Nonnull Throwable ex) { Object[] logInfo; if (ex instanceof LoggableKeysAndValues) { logInfo = ((LoggableKeysAndValues)ex).exportLogInfo(); } else { logInfo = EMPTY_KEYS_AND_VALUES; } if (ex instanceof CompletionException) { ex = CompletionExceptionLogHelper.asCause((CompletionException)ex); } else if (ex instanceof ExecutionException) { ex = CompletionExceptionLogHelper.asCause((ExecutionException)ex); } if (ex instanceof FDBException) { FDBException fdbex = (FDBException)ex; switch (fdbex.getCode()) { case 1007: return new FDBStoreTransactionIsTooOldException(fdbex).addLogInfo(logInfo); case 1020: return new FDBStoreTransactionConflictException(fdbex).addLogInfo(logInfo); case 1031: return new FDBStoreTransactionTimeoutException(fdbex).addLogInfo(logInfo); case 2101: return new FDBStoreTransactionSizeException(fdbex).addLogInfo(logInfo); case 2102: return new FDBStoreKeySizeException(fdbex).addLogInfo(logInfo); case 2103: return new FDBStoreValueSizeException(fdbex).addLogInfo(logInfo); default: if (fdbex.isRetryable()) { return new FDBStoreRetriableException(fdbex).addLogInfo(logInfo); } else { return new FDBStoreException(fdbex).addLogInfo(logInfo); } } } if (ex instanceof RuntimeException) { return (RuntimeException)ex; } if (ex instanceof InterruptedException) { return new RecordCoreInterruptedException(ex.getMessage(), ex).addLogInfo(logInfo); } return new RecordCoreException(ex.getMessage(), ex).addLogInfo(logInfo); } private  FDBExceptions(); static RuntimeException wrapException(@Nonnull Throwable ex); static boolean isRetriable(@Nullable Throwable ex); @Nullable static FDBException getFDBCause(@Nullable Throwable ex);  }