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

How to use
getSuppressed
method
in
java.lang.RuntimeException

Best Java code snippets using java.lang.RuntimeException.getSuppressed (Showing top 19 results out of 315)

origin: neo4j/neo4j

@Test
void shouldThrowAppropriateExceptionIfBothStartAndShutdownFail()
{
  RuntimeException startupError = new RuntimeException();
  RuntimeException shutdownError = new RuntimeException();
  GraphDatabaseFacadeFactory db = newFaultyGraphDatabaseFacadeFactory( startupError );
  doThrow( shutdownError ).when( mockFacade ).shutdown();
  RuntimeException initException =
      assertThrows( RuntimeException.class, () -> db.initFacade( testDirectory.storeDir(), Collections.emptyMap(), deps, mockFacade ) );
  assertTrue( initException.getMessage().startsWith( "Error starting " ) );
  assertEquals( startupError, initException.getCause() );
  assertEquals( shutdownError, initException.getSuppressed()[0] );
}
origin: jdbi/jdbi

@Test
public void testRollbackThrow() throws Exception {
  RuntimeException outer = new RuntimeException("Transaction throws!");
  RuntimeException inner = new RuntimeException("Rollback throws!");
  Mockito.when(c.getAutoCommit()).thenReturn(true);
  Mockito.when(h.getConnection()).thenReturn(c);
  Mockito.when(h.rollback()).thenThrow(inner);
  try {
    new LocalTransactionHandler().inTransaction(h, x -> {
      throw outer;
    });
  } catch (RuntimeException e) {
    assertThat(e).isSameAs(outer);
    assertThat(e.getSuppressed()).hasSize(1);
    assertThat(e.getSuppressed()[0]).isSameAs(inner);
  }
}
origin: Alluxio/alluxio

@Test
public void throwTwoRuntimeExceptions() throws Throwable {
 Exception bdcException = new IllegalStateException("block deletion context exception");
 Exception jcException = new IllegalArgumentException("journal context exception");
 doThrow(bdcException).when(mMockBDC).close();
 doThrow(jcException).when(mMockJC).close();
 try {
  mRpcContext.close();
  fail("Expected an exception to be thrown");
 } catch (RuntimeException e) {
  assertEquals(jcException, e);
  // journal context is closed first, so the block deletion context exception should be
  // suppressed.
  assertEquals(bdcException, e.getSuppressed()[0]);
 }
}
origin: neo4j/neo4j

assertTrue( failed.hasNext() );
assertEquals( e.getMessage(), failed.next() );
for ( Throwable suppressed : e.getSuppressed() )
origin: prestodb/presto

if (closeError.getSuppressed().length > 0) {
  throw closeError;
origin: io.ratpack/ratpack-core

private static ImmutableSet<ConfigObject<?>> extractRequiredConfig(ConfigData configData, Map<String, TypeToken<?>> required) {
 RuntimeException badConfig = new IllegalStateException("Failed to build required config items");
 ImmutableSet.Builder<ConfigObject<?>> config = ImmutableSet.builder();
 for (Map.Entry<String, TypeToken<?>> requiredConfig : required.entrySet()) {
  String path = requiredConfig.getKey();
  TypeToken<?> type = requiredConfig.getValue();
  try {
   config.add(configData.getAsConfigObject(path, type));
  } catch (Exception e) {
   badConfig.addSuppressed(new IllegalStateException("Could not bind config at '" + path + "' to '" + type + "'", e));
  }
 }
 if (badConfig.getSuppressed().length > 0) {
  throw badConfig;
 } else {
  return config.build();
 }
}
origin: reactor/reactive-streams-commons

/**
 * Loops through all values in the set and collects any exceptions from the consumer
 * into a Throwable.
 * @param consumer the consumer to call
 * @return if not null, contains a CompositeException with all the suppressed exceptions
 */
public Throwable forEachSuppress(Consumer<? super T> consumer) {
  RuntimeException ex = null;
  int count = 0;
  for (T k : keys) {
    if (k != null) {
      try {
        consumer.accept(k);
      } catch (Throwable e) {
        if (ex == null) {
          ex = new RuntimeException("Multiple exceptions");
        }
        count++;
        ex.addSuppressed(e);
      }
    }
  }
  if (count == 1) {
    return ex.getSuppressed()[0];
  }
  return ex;
}

origin: org.nuxeo.ecm.core/nuxeo-core-schema

if (errors.getSuppressed().length > 0) {
  throw errors;
origin: prestosql/presto

@Override
public void abort()
{
  RuntimeException error = new RuntimeException("Exception during rollback");
  for (PageBuffer pageBuffer : pageWriter.getPageBuffers()) {
    try {
      pageBuffer.getStoragePageSink().rollback();
    }
    catch (Throwable t) {
      // Self-suppression not permitted
      if (error != t) {
        error.addSuppressed(t);
      }
    }
  }
  if (error.getSuppressed().length > 0) {
    throw error;
  }
}
origin: com.facebook.presto/presto-raptor

@Override
public void abort()
{
  RuntimeException error = new RuntimeException("Exception during rollback");
  for (PageBuffer pageBuffer : pageWriter.getPageBuffers()) {
    try {
      pageBuffer.getStoragePageSink().rollback();
    }
    catch (Throwable t) {
      // Self-suppression not permitted
      if (error != t) {
        error.addSuppressed(t);
      }
    }
  }
  if (error.getSuppressed().length > 0) {
    throw error;
  }
}
origin: sniffy/sniffy

@Test
public void testTryWithResourceApi_Never() throws Exception {
  try {
    try (Spy ignored = Sniffer.expectNever()) {
      executeStatement();
      throw new RuntimeException("This is a test exception");
    }
  } catch (RuntimeException e) {
    assertEquals("This is a test exception", e.getMessage());
    assertNotNull(e.getSuppressed());
    assertEquals(1, e.getSuppressed().length);
    assertTrue(WrongNumberOfQueriesError.class.isAssignableFrom(e.getSuppressed()[0].getClass()));
  }
}
origin: sniffy/sniffy

@Test
public void testExecuteThrowsException() throws Exception {
  try {
    Sniffer.expect(1).execute(() -> {
      throw new RuntimeException();
    });
  } catch (RuntimeException e) {
    assertNotNull(e);
    assertNull(e.getCause());
    assertEquals(1, e.getSuppressed().length);
    assertTrue(WrongNumberOfQueriesError.class.isAssignableFrom(e.getSuppressed()[0].getClass()));
  }
}
origin: sniffy/sniffy

@Test
public void testRunThrowsException() throws Exception {
  try {
    Sniffer.expect(1).run(() -> {
      throw new RuntimeException();
    });
  } catch (RuntimeException e) {
    assertNotNull(e);
    assertNull(e.getCause());
    assertEquals(1, e.getSuppressed().length);
    assertTrue(WrongNumberOfQueriesError.class.isAssignableFrom(e.getSuppressed()[0].getClass()));
  }
}
origin: sniffy/sniffy

@Test
public void testCallThrowsException() throws Exception {
  try {
    Sniffer.expect(1).call(() -> {
      throw new RuntimeException();
    });
  } catch (RuntimeException e) {
    assertNotNull(e);
    assertNull(e.getCause());
    assertEquals(1, e.getSuppressed().length);
    assertTrue(WrongNumberOfQueriesError.class.isAssignableFrom(e.getSuppressed()[0].getClass()));
  }
}
origin: uk.co.nichesolutions.presto/presto-main

if (closeError.getSuppressed().length > 0) {
  throw closeError;
origin: io.prestosql/presto-main

if (closeError.getSuppressed().length > 0) {
  throw closeError;
origin: prestosql/presto

if (closeError.getSuppressed().length > 0) {
  throw closeError;
origin: vmware/xenon

} catch (RuntimeException e) {
  throw ExceptionTestUtils.throwAsUnchecked(e.getSuppressed()[0]);
origin: com.vmware.xenon/xenon-common

} catch (RuntimeException e) {
  throw ExceptionTestUtils.throwAsUnchecked(e.getSuppressed()[0]);
java.langRuntimeExceptiongetSuppressed

Popular methods of RuntimeException

  • <init>
  • getMessage
  • printStackTrace
  • getCause
  • toString
  • getStackTrace
  • initCause
  • setStackTrace
  • getLocalizedMessage
  • fillInStackTrace
  • addSuppressed
  • addSuppressed

Popular in Java

  • Making http requests using okhttp
  • getResourceAsStream (ClassLoader)
  • getApplicationContext (Context)
  • scheduleAtFixedRate (Timer)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Top PhpStorm 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