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

How to use
addSuppressed
method
in
java.lang.RuntimeException

Best Java code snippets using java.lang.RuntimeException.addSuppressed (Showing top 20 results out of 765)

origin: apache/incubator-druid

private void runCallbacks()
{
 RuntimeException e = null;
 for (Runnable callback = shutdownCallbacks.poll(); callback != null; callback = shutdownCallbacks.poll()) {
  try {
   callback.run();
  }
  catch (RuntimeException ex) {
   if (e == null) {
    e = new RuntimeException("Error running callback");
   }
   e.addSuppressed(ex);
  }
 }
 if (e != null) {
  throw e;
 }
}
origin: neo4j/neo4j

  /**
   * If the given obj is AutoCloseable, then close it.
   * Any exceptions thrown from the close method will be wrapped in RuntimeExceptions.
   * These RuntimeExceptions can get the given suppressedException attached to them, if any.
   * If the given suppressedException argument is null, then it will not be added to the
   * thrown RuntimeException.
   */
  static void closeSafely( Object obj, Throwable suppressedException )
  {
    if ( obj instanceof AutoCloseable )
    {
      AutoCloseable closeable = (AutoCloseable) obj;
      try
      {
        closeable.close();
      }
      catch ( Exception cause )
      {
        RuntimeException exception = new RuntimeException( cause );
        if ( suppressedException != null )
        {
          exception.addSuppressed( suppressedException );
        }
        throw exception;
      }
    }
  }
}
origin: neo4j/neo4j

  /**
   * If the given obj is AutoCloseable, then close it.
   * Any exceptions thrown from the close method will be wrapped in RuntimeExceptions.
   * These RuntimeExceptions can get the given suppressedException attached to them, if any.
   * If the given suppressedException argument is null, then it will not be added to the
   * thrown RuntimeException.
   */
  static void closeSafely( Object obj, Throwable suppressedException )
  {
    if ( obj instanceof AutoCloseable )
    {
      AutoCloseable closeable = (AutoCloseable) obj;
      try
      {
        closeable.close();
      }
      catch ( Exception cause )
      {
        RuntimeException exception = new RuntimeException( cause );
        if ( suppressedException != null )
        {
          exception.addSuppressed( suppressedException );
        }
        throw exception;
      }
    }
  }
}
origin: reactor/reactor-core

/**
 * Create a composite exception that wraps the given {@link Throwable Throwable(s)},
 * as suppressed exceptions. Instances create by this method can be detected using the
 * {@link #isMultiple(Throwable)} check. The {@link #unwrapMultiple(Throwable)} method
 * will correctly unwrap these to a {@link List} of the suppressed exceptions. Note
 * that is will also be consistent in producing a List for other types of exceptions
 * by putting the input inside a single-element List.
 *
 * @param throwables the exceptions to wrap into a composite
 * @return a composite exception with a standard message, and the given throwables as
 * suppressed exceptions
 * @see #addThrowable(AtomicReferenceFieldUpdater, Object, Throwable)
 */
public static RuntimeException multiple(Iterable<Throwable> throwables) {
  RuntimeException multiple = new RuntimeException("Multiple exceptions");
  //noinspection ConstantConditions
  if (throwables != null) {
    for (Throwable t : throwables) {
      //this is ok, multiple is always a new non-singleton instance
      multiple.addSuppressed(t);
    }
  }
  return multiple;
}
origin: apache/storm

  @Override
  public void close() {
    if (closed) {
      return;
    }
    RuntimeException saved = null;
    for (Iterator<String> it = super.iterator(); it.hasNext();) {
      String name = it.next();
      try {
        client.killTopologyWithOpts(name, NO_WAIT_KILL);
        it.remove();
      } catch (Exception e) {
        RuntimeException wrapped = new RuntimeException("Error trying to kill " + name, e);
        if (saved != null) {
          saved.addSuppressed(wrapped);
        } else {
          saved = wrapped;
        }
      }
    }
    super.clear();
    if (saved != null) {
      throw saved;
    }
    closed = true;
  }
}
origin: embulk/embulk

public RuntimeException getRepresentativeException() {
  RuntimeException top = null;
  for (Throwable ex : getExceptions()) {
    if (top != null) {
      top.addSuppressed(ex);
    } else {
      if (ex instanceof RuntimeException) {
        top = (RuntimeException) ex;
      } else {
        top = new RuntimeException(ex);
      }
    }
  }
  if (top == null) {
    top = new RuntimeException("Some transactions are not committed");
  }
  return top;
}
origin: konsoletyper/teavm

  @Override
  public void close() throws Exception {
    RuntimeException previousException = null;
    try {
      closeHandler.run();
    } catch (RuntimeException e) {
      previousException = e;
    }

    try {
      innerStream.close();
    } catch (RuntimeException e) {
      if (previousException != null) {
        e.addSuppressed(previousException);
      }
      throw e;
    }
  }
}
origin: konsoletyper/teavm

  @Override
  public void close() throws Exception {
    RuntimeException previousException = null;
    try {
      closeHandler.run();
    } catch (RuntimeException e) {
      previousException = e;
    }

    try {
      innerStream.close();
    } catch (RuntimeException e) {
      if (previousException != null) {
        e.addSuppressed(previousException);
      }
      throw e;
    }
  }
}
origin: konsoletyper/teavm

  @Override
  public void close() throws Exception {
    RuntimeException previousException = null;
    try {
      closeHandler.run();
    } catch (RuntimeException e) {
      previousException = e;
    }

    try {
      innerStream.close();
    } catch (RuntimeException e) {
      if (previousException != null) {
        e.addSuppressed(previousException);
      }
      throw e;
    }
  }
}
origin: konsoletyper/teavm

  @Override
  public void close() throws Exception {
    RuntimeException previousException = null;
    try {
      closeHandler.run();
    } catch (RuntimeException e) {
      previousException = e;
    }

    try {
      innerStream.close();
    } catch (RuntimeException e) {
      if (previousException != null) {
        e.addSuppressed(previousException);
      }
      throw e;
    }
  }
}
origin: com.h2database/h2

e.addSuppressed(e2);
throw e;
origin: konsoletyper/teavm

  @Override
  public void close() throws Exception {
    RuntimeException suppressed = null;
    try {
      first.close();
    } catch (RuntimeException e) {
      suppressed = e;
    }
    try {
      second.close();
    } catch (RuntimeException e) {
      if (suppressed != null) {
        e.addSuppressed(suppressed);
      }
      throw e;
    }
  }
}
origin: konsoletyper/teavm

  @Override
  public void close() throws Exception {
    RuntimeException suppressed = null;
    try {
      first.close();
    } catch (RuntimeException e) {
      suppressed = e;
    }
    try {
      second.close();
    } catch (RuntimeException e) {
      if (suppressed != null) {
        e.addSuppressed(suppressed);
      }
      throw e;
    }
  }
}
origin: konsoletyper/teavm

  @Override
  public void close() throws Exception {
    RuntimeException suppressed = null;
    try {
      first.close();
    } catch (RuntimeException e) {
      suppressed = e;
    }
    try {
      second.close();
    } catch (RuntimeException e) {
      if (suppressed != null) {
        e.addSuppressed(suppressed);
      }
      throw e;
    }
  }
}
origin: konsoletyper/teavm

  @Override
  public void close() throws Exception {
    RuntimeException suppressed = null;
    try {
      first.close();
    } catch (RuntimeException e) {
      suppressed = e;
    }
    try {
      second.close();
    } catch (RuntimeException e) {
      if (suppressed != null) {
        e.addSuppressed(suppressed);
      }
      throw e;
    }
  }
}
origin: neo4j/neo4j

  @Override
  public void close()
  {
    RuntimeException exception = null;
    for ( Pair<SnapshotDeletionPolicy,IndexCommit> policyAndCommit : snapshots )
    {
      try
      {
        policyAndCommit.first().release( policyAndCommit.other() );
      }
      catch ( IOException | RuntimeException e )
      {
        if ( exception == null )
        {
          exception = e instanceof IOException ?
                new UncheckedIOException( (IOException) e ) :
                (RuntimeException) e;
        }
        else
        {
          exception.addSuppressed( e );
        }
      }
    }
    if ( exception != null )
    {
      throw exception;
    }
  }
};
origin: jenkinsci/jenkins

RuntimeException exception = new RuntimeException(message.toString(), iterator.next());
while (iterator.hasNext()) {
  exception.addSuppressed(iterator.next());
origin: apache/incubator-druid

public static void cleanup(Job job) throws IOException
{
 final Path jobDir = getJobPath(job.getJobID(), job.getWorkingDirectory());
 final FileSystem fs = jobDir.getFileSystem(job.getConfiguration());
 RuntimeException e = null;
 try {
  JobHelper.deleteWithRetry(fs, jobDir, true);
 }
 catch (RuntimeException ex) {
  e = ex;
 }
 try {
  JobHelper.deleteWithRetry(fs, getJobClassPathDir(job.getJobName(), job.getWorkingDirectory()), true);
 }
 catch (RuntimeException ex) {
  if (e == null) {
   e = ex;
  } else {
   e.addSuppressed(ex);
  }
 }
 if (e != null) {
  throw e;
 }
}
origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testXGetSuppressedList() throws Exception {
  IgniteCheckedException me = prepareMultiException();
  assertEquals(3, X.getSuppressedList(me).size());
  RuntimeException e = new RuntimeException();
  e.addSuppressed(me);
  List<Throwable> suppresseds = X.getSuppressedList(e);
  assertEquals(4, suppresseds.size());
  assertEquals("Test message.", suppresseds.get(0).getMessage());
  for (int i = 1; i <= 3; i++)
    assertEquals("Demo exception.", suppresseds.get(1).getMessage());
}
origin: neo4j/neo4j

initException.addSuppressed( closeException );
java.langRuntimeExceptionaddSuppressed

Popular methods of RuntimeException

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

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • findViewById (Activity)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • CodeWhisperer alternatives
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