Tabnine Logo
Throwable.getSuppressed
Code IndexAdd Tabnine to your IDE (free)

How to use
getSuppressed
method
in
java.lang.Throwable

Best Java code snippets using java.lang.Throwable.getSuppressed (Showing top 20 results out of 954)

origin: org.assertj/assertj-core

private ShouldHaveSuppressedException(Throwable actual, Throwable expectedSuppressedException) {
 super("%n" +
    "Expecting:%n" +
    "  <%s>%n" +
    "to have a suppressed exception with the following type and message:%n" +
    "  <%s> / <%s>%n" +
    "but could not find any in actual's suppressed exceptions:%n" +
    "  <%s>.",
    actual, expectedSuppressedException.getClass().getName(), expectedSuppressedException.getMessage(),
    actual.getSuppressed());
}
origin: joel-costigliola/assertj-core

private ShouldHaveSuppressedException(Throwable actual, Throwable expectedSuppressedException) {
 super("%n" +
    "Expecting:%n" +
    "  <%s>%n" +
    "to have a suppressed exception with the following type and message:%n" +
    "  <%s> / <%s>%n" +
    "but could not find any in actual's suppressed exceptions:%n" +
    "  <%s>.",
    actual, expectedSuppressedException.getClass().getName(), expectedSuppressedException.getMessage(),
    actual.getSuppressed());
}
origin: apache/ignite

  /** {@inheritDoc} */
  @Override public void serialize(Throwable e, JsonGenerator gen, SerializerProvider ser) throws IOException {
    gen.writeStartObject();
    writeException(e, gen);
    if (e.getCause() != null)
      gen.writeObjectField("cause", e.getCause());
    if (!F.isEmpty(e.getSuppressed())) {
      gen.writeArrayFieldStart("suppressed");
      for (Throwable sup : e.getSuppressed())
        gen.writeObject(sup);
      gen.writeEndArray();
    }
    gen.writeEndObject();
  }
};
origin: apache/hive

 @VisibleForTesting
 static RuntimeException convertToSerializableSparkException(Throwable error) {
  RuntimeException serializableThrowable = new RuntimeException(
      error.getClass().getName() + ": " + Objects.toString(error.getMessage(), ""),
      error.getCause() == null ? null : convertToSerializableSparkException(
          error.getCause()));

  serializableThrowable.setStackTrace(error.getStackTrace());

  Arrays.stream(error.getSuppressed())
      .map(JobResultSerializer::convertToSerializableSparkException)
      .forEach(serializableThrowable::addSuppressed);

  return serializableThrowable;
 }
}
origin: neo4j/neo4j

@Override
protected boolean matchesSafely( Throwable item )
{
  return Arrays.equals( item.getSuppressed(), expectedSuppressedErrors );
}
origin: apache/ignite

/**
 * Collects suppressed exceptions from throwable and all it causes.
 *
 * @param t Throwable.
 * @return List of suppressed throwables.
 */
public static List<Throwable> getSuppressedList(@Nullable Throwable t) {
  List<Throwable> result = new ArrayList<>();
  if (t == null)
    return result;
  do {
    for (Throwable suppressed : t.getSuppressed()) {
      result.add(suppressed);
      result.addAll(getSuppressedList(suppressed));
    }
  } while ((t = t.getCause()) != null);
  return result;
}
origin: apache/ignite

/**
 * Checks if passed throwable has given class in one of the suppressed exceptions.
 *
 * @param t Throwable to check (if {@code null}, {@code false} is returned).
 * @param cls Class to check.
 * @return {@code True} if one of the suppressed exceptions is an instance of passed class,
 *      {@code false} otherwise.
 */
public static boolean hasSuppressed(@Nullable Throwable t, @Nullable Class<? extends Throwable> cls) {
  if (t == null || cls == null)
    return false;
  for (Throwable th : t.getSuppressed()) {
    if (cls.isAssignableFrom(th.getClass()))
      return true;
    if (hasSuppressed(th, cls))
      return true;
  }
  return false;
}
origin: jenkinsci/jenkins

  doPrintStackTrace(s, lower, t, prefix, encountered);
for (Throwable suppressed : t.getSuppressed()) {
  s.append(prefix).append("Also:   ");
  doPrintStackTrace(s, suppressed, t, prefix + "\t", encountered);
origin: org.assertj/assertj-core

public void assertHasNoSuppressedExceptions(AssertionInfo info, Throwable actual) {
 assertNotNull(info, actual);
 Throwable[] suppressed = actual.getSuppressed();
 if (suppressed.length != 0) throw failures.failure(info, shouldHaveNoSuppressedExceptions(suppressed));
}
origin: RuedigerMoeller/fast-serialization

@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo,
            FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
  Throwable t = (Throwable)toWrite;
  out.writeStringUTF(t.getMessage());
  StackTraceElement[] ste = t.getStackTrace();
  out.writeObject(ste);
  out.writeObject(t.getCause());
  out.writeObject(t.getSuppressed());
}
origin: joel-costigliola/assertj-core

public void assertHasNoSuppressedExceptions(AssertionInfo info, Throwable actual) {
 assertNotNull(info, actual);
 Throwable[] suppressed = actual.getSuppressed();
 if (suppressed.length != 0) throw failures.failure(info, shouldHaveNoSuppressedExceptions(suppressed));
}
origin: org.assertj/assertj-core

public void assertHasSuppressedException(AssertionInfo info, Throwable actual,
                     Throwable expectedSuppressedException) {
 assertNotNull(info, actual);
 checkNotNull(expectedSuppressedException, "The expected suppressed exception should not be null");
 Throwable[] suppressed = actual.getSuppressed();
 for (int i = 0; i < suppressed.length; i++) {
  if (compareThrowable(suppressed[i], expectedSuppressedException)) return;
 }
 throw failures.failure(info, shouldHaveSuppressedException(actual, expectedSuppressedException));
}
origin: reactor/reactor-core

@Test
public void whenIterableDelayErrorPublishersVoidCombinesErrors() {
  Exception boom1 = new NullPointerException("boom1");
  Exception boom2 = new IllegalArgumentException("boom2");
  Iterable<Publisher<Void>> voidPublishers = Arrays.asList(
      Mono.<Void>empty(),
      Mono.<Void>error(boom1),
      Mono.<Void>error(boom2));
  StepVerifier.create(Mono.whenDelayError(voidPublishers))
        .verifyErrorMatches(e -> e.getMessage().equals("Multiple exceptions") &&
            e.getSuppressed()[0] == boom1 &&
            e.getSuppressed()[1] == boom2);
}
origin: reactor/reactor-core

private void printAndAssert(Throwable t, boolean checkForAssemblySuppressed) {
  t.printStackTrace();
  assertThat(t)
      .isInstanceOf(IndexOutOfBoundsException.class)
      .hasMessage("Source emitted more than one item");
  if (!checkForAssemblySuppressed) {
    assertThat(t).hasNoSuppressedExceptions();
  }
  else {
    assertThat(t).satisfies(withSuppressed -> {
      assertThat(withSuppressed.getSuppressed()).hasSize(1);
      assertThat(withSuppressed.getSuppressed()[0])
          .hasMessageStartingWith("\nAssembly trace from producer [reactor.core.publisher.MonoSingle] :")
          .hasMessageEndingWith("Flux.single ⇢ reactor.guide.GuideTests.scatterAndGather(GuideTests.java:944)\n");
    });
  }
}
origin: reactor/reactor-core

@Test
public void whenIterableDelayErrorCombinesErrors() {
  Exception boom1 = new NullPointerException("boom1");
  Exception boom2 = new IllegalArgumentException("boom2");
  StepVerifier.create(Mono.zipDelayError(
      Arrays.asList(Mono.just("foo"), Mono.<String>error(boom1), Mono.<String>error(boom2)),
      Tuples.fn3()))
        .verifyErrorMatches(e -> e.getMessage().equals("Multiple exceptions") &&
            e.getSuppressed()[0] == boom1 &&
            e.getSuppressed()[1] == boom2);
}
origin: joel-costigliola/assertj-core

public void assertHasSuppressedException(AssertionInfo info, Throwable actual,
                     Throwable expectedSuppressedException) {
 assertNotNull(info, actual);
 checkNotNull(expectedSuppressedException, "The expected suppressed exception should not be null");
 Throwable[] suppressed = actual.getSuppressed();
 for (int i = 0; i < suppressed.length; i++) {
  if (compareThrowable(suppressed[i], expectedSuppressedException)) return;
 }
 throw failures.failure(info, shouldHaveSuppressedException(actual, expectedSuppressedException));
}
origin: reactor/reactor-core

@Test
public void addThrowableRace() throws Exception {
  for (int i = 0; i < 10; i++) {
    final int idx = i;
    RaceTestUtils.race(
        () -> Exceptions.addThrowable(ADD_THROWABLE, ExceptionsTest.this, new IllegalStateException("boomState" + idx)),
        () -> Exceptions.addThrowable(ADD_THROWABLE, ExceptionsTest.this, new IllegalArgumentException("boomArg" + idx))
    );
  }
  assertThat(addThrowable.getSuppressed())
      .hasSize(20);
}
origin: reactor/reactor-core

@Test
public void errorCallbackError() {
  IllegalStateException err = new IllegalStateException("test");
  FluxPeekFuseable<String> flux = new FluxPeekFuseable<>(
      Flux.error(new IllegalArgumentException("bar")), null, null,
      e -> { throw err; },
      null, null, null, null);
  AssertSubscriber<String> ts = AssertSubscriber.create();
  flux.subscribe(ts);
  ts.assertNoValues();
  ts.assertError(IllegalStateException.class);
  ts.assertErrorWith(e -> e.getSuppressed()[0].getMessage().equals("bar"));
}
origin: reactor/reactor-core

@Test
public void sourceFactoryAndResourceCleanupThrow() {
  RuntimeException sourceEx = new IllegalStateException("sourceFactory");
  RuntimeException cleanupEx = new IllegalStateException("resourceCleanup");
  Condition<? super Throwable> suppressingFactory = new Condition<>(
      e -> {
        Throwable[] suppressed = e.getSuppressed();
        return suppressed != null && suppressed.length == 1 && suppressed[0] == sourceEx;
      }, "suppressing <%s>", sourceEx);
  Flux<String> test = new FluxUsing<>(() -> "foo",
      o -> { throw sourceEx; },
      s -> { throw cleanupEx; },
      false);
  StepVerifier.create(test)
        .verifyErrorSatisfies(e -> assertThat(e)
            .hasMessage("resourceCleanup")
            .is(suppressingFactory));
}
origin: prestodb/presto

@Test
public void testSuppressedException()
{
  RuntimeException runtimeException = new RuntimeException();
  Exception exception = new Exception();
  Error error = new Error();
  AutoCloseableCloser closer = AutoCloseableCloser.create();
  // add twice to test self suppression handling
  closer.register(failingCloseable(error));
  closer.register(failingCloseable(error));
  closer.register(failingCloseable(exception));
  closer.register(failingCloseable(exception));
  closer.register(failingCloseable(runtimeException));
  closer.register(failingCloseable(runtimeException));
  try {
    closer.close();
    fail("expected to fail");
  }
  catch (Throwable t) {
    assertSame(t, runtimeException);
    assertSame(t.getSuppressed()[0], exception);
    assertSame(t.getSuppressed()[1], exception);
    assertSame(t.getSuppressed()[2], error);
    assertSame(t.getSuppressed()[3], error);
  }
}
java.langThrowablegetSuppressed

Javadoc

Returns the throwables suppressed by this.

Popular methods of Throwable

  • getMessage
    Returns the detail message string of this throwable.
  • printStackTrace
  • getCause
    Returns the cause of this throwable or null if the cause is nonexistent or unknown. (The cause is th
  • toString
    Returns a short description of this throwable. The result is the concatenation of: * the Class#getN
  • getStackTrace
    Provides programmatic access to the stack trace information printed by #printStackTrace(). Returns a
  • <init>
    Constructs a new throwable with the specified cause and a detail message of (cause==null ? null : ca
  • getLocalizedMessage
    Creates a localized description of this throwable. Subclasses may override this method in order to p
  • setStackTrace
    Sets the stack trace elements that will be returned by #getStackTrace() and printed by #printStackTr
  • addSuppressed
    Appends the specified exception to the exceptions that were suppressed in order to deliver this exce
  • initCause
    Initializes the cause of this throwable to the specified value. (The cause is the throwable that cau
  • fillInStackTrace
  • countDuplicates
    Counts the number of duplicate stack frames, starting from the end of the stack.
  • fillInStackTrace,
  • countDuplicates,
  • getInternalStackTrace,
  • nativeFillInStackTrace,
  • nativeGetStackTrace,
  • fillInStackTrace0,
  • genStackTrace,
  • genStackTraceFromError,
  • getOurStackTrace

Popular in Java

  • Updating database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • getApplicationContext (Context)
  • getContentResolver (Context)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • JPanel (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now