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

How to use
getSuppressed
method
in
java.lang.Exception

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

origin: wildfly/wildfly

  private static <T extends Throwable> T copyContents(final Exception source, final T throwable) {
    throwable.setStackTrace(source.getStackTrace());
    final Throwable[] suppressed = source.getSuppressed();
    if (suppressed != null) for (final Throwable t : suppressed) {
      throwable.addSuppressed(t);
    }
    return throwable;
  }
}
origin: neo4j/neo4j

  @Override
  public boolean matches( Object item )
  {
    Exception e = (Exception) item;
    for ( Throwable suppressed : e.getSuppressed() )
    {
      if ( suppressed instanceof ResourceCloseFailureException )
      {
        if ( suppressed.getCause() instanceof ExceptionDuringClose )
        {
          return true;
        }
      }
    }
    return false;
  }
} );
origin: SonarSource/sonarqube

@Test
public void log_error_as_suppressed_when_task_failed_with_MessageException_and_ending_state_can_not_be_persisted_to_db() throws Exception {
 CeTask ceTask = createCeTask(submitter);
 when(queue.peek(anyString())).thenReturn(Optional.of(ceTask));
 taskProcessorRepository.setProcessorForTask(CeTaskTypes.REPORT, taskProcessor);
 MessageException ex = makeTaskProcessorFail(ceTask, MessageException.of("simulate MessageException thrown by TaskProcessor#process"));
 RuntimeException runtimeException = new RuntimeException("Simulate queue#remove failing");
 doThrow(runtimeException).when(queue).remove(ceTask, CeActivityDto.Status.FAILED, null, ex);
 underTest.call();
 List<String> logs = logTester.logs(LoggerLevel.INFO);
 assertThat(logs).hasSize(2);
 assertThat(logs.get(0)).contains(" | submitter=" + submitter.getLogin());
 assertThat(logs.get(1)).contains(String.format(" | submitter=%s | status=FAILED | time=", submitter.getLogin()));
 List<LogAndArguments> logAndArguments = logTester.getLogs(LoggerLevel.ERROR);
 assertThat(logAndArguments).hasSize(1);
 assertThat(logAndArguments.get(0).getFormattedMsg()).isEqualTo("Failed to finalize task with uuid '" + ceTask.getUuid() + "' and persist its state to db");
 Object arg1 = logAndArguments.get(0).getArgs().get()[0];
 assertThat(arg1).isSameAs(runtimeException);
 assertThat(((Exception) arg1).getSuppressed()).containsOnly(ex);
}
origin: reactor/reactor-core

@Test
public void testTrace2() throws Exception {
  Hooks.onOperatorDebug();
  try {
    Mono.just(1)
      .map(d -> {
        throw new RuntimeException();
      })
      .filter(d -> true)
      .doOnNext(d -> System.currentTimeMillis())
      .map(d -> d)
      .block();
  }
  catch(Exception e){
    e.printStackTrace();
    Assert.assertTrue(e.getSuppressed()[0].getMessage().contains
        ("HooksTraceTest.java:"));
    Assert.assertTrue(e.getSuppressed()[0].getMessage().contains("|_\tMono.map ⇢ reactor.HooksTraceTest.testTrace2(HooksTraceTest.java:"));
    return;
  }
  finally {
    Hooks.resetOnOperatorDebug();
  }
  throw new IllegalStateException();
}
origin: reactor/reactor-core

@Test
public void testTraceComposed() throws Exception {
  Hooks.onOperatorDebug();
  try {
    Mono.just(1)
      .flatMap(d -> Mono.error(new RuntimeException()))
      .filter(d -> true)
      .doOnNext(d -> System.currentTimeMillis())
      .map(d -> d)
      .block();
  }
  catch (Exception e) {
    e.printStackTrace();
    Assert.assertTrue(e.getSuppressed()[0].getMessage()
                       .contains("HooksTraceTest.java:"));
    Assert.assertTrue(e.getSuppressed()[0].getMessage()
                       .contains("|_\tMono.flatMap ⇢ reactor.HooksTraceTest.testTraceComposed(HooksTraceTest.java:"));
    return;
  }
  finally {
    Hooks.resetOnOperatorDebug();
  }
  throw new IllegalStateException();
}
origin: reactor/reactor-core

@Test
public void testTrace() throws Exception {
  Hooks.onOperatorDebug();
  try {
    Mono.fromCallable(() -> {
      throw new RuntimeException();
    })
      .map(d -> d)
      .block();
  }
  catch(Exception e){
    e.printStackTrace();
    Assert.assertTrue(e.getSuppressed()[0].getMessage().contains("MonoCallable"));
    return;
  }
  finally {
    Hooks.resetOnOperatorDebug();
  }
  throw new IllegalStateException();
}
origin: reactor/reactor-core

@Test
public void testTraceDefer() throws Exception {
  Hooks.onOperatorDebug();
  try {
    Mono.defer(() -> Mono.just(1)
               .flatMap(d -> Mono.error(new RuntimeException()))
               .filter(d -> true)
               .doOnNext(d -> System.currentTimeMillis())
               .map(d -> d))
      .block();
  }
  catch(Exception e){
    e.printStackTrace();
    Assert.assertTrue(e.getSuppressed()[0].getMessage().contains
        ("HooksTraceTest.java:"));
    Assert.assertTrue(e.getSuppressed()[0].getMessage().contains("|_\tMono.flatMap ⇢ reactor.HooksTraceTest.lambda$testTraceDefer$14(HooksTraceTest.java:"));
    return;
  }
  finally {
    Hooks.resetOnOperatorDebug();
  }
  throw new IllegalStateException();
}
origin: SonarSource/sonarqube

@Test
public void log_error_when_task_failed_and_ending_state_can_not_be_persisted_to_db() throws Exception {
 CeTask ceTask = createCeTask(submitter);
 when(queue.peek(anyString())).thenReturn(Optional.of(ceTask));
 taskProcessorRepository.setProcessorForTask(CeTaskTypes.REPORT, taskProcessor);
 IllegalStateException ex = makeTaskProcessorFail(ceTask);
 RuntimeException runtimeException = new RuntimeException("Simulate queue#remove failing");
 doThrow(runtimeException).when(queue).remove(ceTask, CeActivityDto.Status.FAILED, null, ex);
 underTest.call();
 List<String> logs = logTester.logs(LoggerLevel.INFO);
 assertThat(logs).hasSize(2);
 assertThat(logs.get(0)).contains(" | submitter=" + submitter.getLogin());
 assertThat(logs.get(1)).contains(String.format(" | submitter=%s | status=FAILED | time=", submitter.getLogin()));
 List<LogAndArguments> logAndArguments = logTester.getLogs(LoggerLevel.ERROR);
 assertThat(logAndArguments).hasSize(2);
 LogAndArguments executionErrorLog = logAndArguments.get(0);
 assertThat(executionErrorLog.getFormattedMsg()).isEqualTo("Failed to execute task " + ceTask.getUuid());
 assertThat(executionErrorLog.getArgs().get()).containsOnly(ceTask.getUuid(), ex);
 LogAndArguments finalizingErrorLog = logAndArguments.get(1);
 assertThat(finalizingErrorLog.getFormattedMsg()).isEqualTo("Failed to finalize task with uuid '" + ceTask.getUuid() + "' and persist its state to db");
 Object arg1 = finalizingErrorLog.getArgs().get()[0];
 assertThat(arg1).isSameAs(runtimeException);
 assertThat(((Exception) arg1).getSuppressed()).containsOnly(ex);
}
origin: reactor/reactor-core

@Test
public void testTrace3() throws Exception {
  Hooks.onOperatorDebug();
  try {
    Flux.just(1)
      .map(d -> {
        throw new RuntimeException();
      })
      .share()
      .filter(d -> true)
      .doOnNext(d -> System.currentTimeMillis())
      .map(d -> d)
      .blockLast();
  }
  catch(Exception e){
    e.printStackTrace();
    Assert.assertTrue(e.getSuppressed()[0].getMessage().contains
        ("HooksTraceTest.java:"));
    Assert.assertTrue(e.getSuppressed()[0].getMessage().contains("|_\tFlux.share ⇢ reactor.HooksTraceTest.testTrace3(HooksTraceTest.java:"));
    return;
  }
  finally {
    Hooks.resetOnOperatorDebug();
  }
  throw new IllegalStateException();
}
origin: reactor/reactor-core

@Test
public void testTraceComposed2() throws Exception {
  Hooks.onOperatorDebug();
  try {
    Flux.just(1)
      .flatMap(d -> {
        throw new RuntimeException();
      })
      .filter(d -> true)
      .doOnNext(d -> System.currentTimeMillis())
      .map(d -> d)
      .blockLast();
  }
  catch(Exception e){
    e.printStackTrace();
    Assert.assertTrue(e.getSuppressed()[0].getMessage().contains
        ("HooksTraceTest.java:"));
    assertThat(e.getSuppressed()[0].getMessage()).contains("|_\tFlux.flatMap ⇢ reactor.HooksTraceTest.testTraceComposed2(HooksTraceTest.java:");
    return;
  }
  finally {
    Hooks.resetOnOperatorDebug();
  }
  throw new IllegalStateException();
}
origin: real-logic/agrona

for (final Throwable suppressed : e.getSuppressed())
for (final Throwable suppressed : e.getSuppressed())
origin: fabric8io/kubernetes-client

logger.error(e.getMessage(), e);
Throwable[] suppressed = e.getSuppressed();
if (suppressed != null) {
 for (Throwable t : suppressed) {
origin: fabric8io/kubernetes-client

public static void main(String[] args) throws InterruptedException {
  String master = "https://localhost:8443/";
  if (args.length == 1) {
    master = args[0];
  }
  Config config = new ConfigBuilder().withMasterUrl(master)
   .withTrustCerts(true)
   .withUsername("admin")
   .withPassword("admin")
   .withNamespace("default")
   .build();
  try (final KubernetesClient client = new AutoAdaptableKubernetesClient(config)) {
   log("Received pods", client.pods().list());
  } catch (Exception e) {
    e.printStackTrace();
    logger.error(e.getMessage(), e);
    Throwable[] suppressed = e.getSuppressed();
    if (suppressed != null) {
      for (Throwable t : suppressed) {
        logger.error(t.getMessage(), t);
      }
    }
  }
}
origin: palatable/lambda

@Test
public void withResourcesPreservesSuppressedExceptionThrownDuringClose() {
  RuntimeException rootException = new RuntimeException();
  IOException nestedIOException = new IOException();
  Try<Exception, Exception> failure = Try.withResources(() -> () -> { throw nestedIOException; },
                             resource -> { throw rootException; });
  Exception thrown = failure.recover(id());
  assertEquals(thrown, rootException);
  assertArrayEquals(new Throwable[]{nestedIOException}, thrown.getSuppressed());
}
origin: org.wildfly.security/wildfly-elytron-mechanism

  private static <T extends Throwable> T copyContents(final Exception source, final T throwable) {
    throwable.setStackTrace(source.getStackTrace());
    final Throwable[] suppressed = source.getSuppressed();
    if (suppressed != null) for (final Throwable t : suppressed) {
      throwable.addSuppressed(t);
    }
    return throwable;
  }
}
origin: org.wildfly.security/wildfly-elytron

  private static <T extends Throwable> T copyContents(final Exception source, final T throwable) {
    throwable.setStackTrace(source.getStackTrace());
    final Throwable[] suppressed = source.getSuppressed();
    if (suppressed != null) for (final Throwable t : suppressed) {
      throwable.addSuppressed(t);
    }
    return throwable;
  }
}
origin: au.net.zeus.jgdms/jgdms-platform

private void writeObject(ObjectOutputStream out) throws IOException {
ObjectOutputStream.PutField pf = out.putFields();
pf.put("message", super.getMessage());
Throwable cause = super.getCause();
if (cause == this) cause = null;
pf.put("cause", cause);
pf.put("stack", super.getStackTrace());
pf.put("suppressed", super.getSuppressed());
out.writeFields();
}
 
origin: org.apache.beam/beam-runners-direct-java

 @Override
 public boolean matches(Object item) {
  if (!(item instanceof Exception)) {
   return false;
  }
  Exception that = (Exception) item;
  return Matchers.containsInAnyOrder(suppressions)
    .matches(ImmutableList.copyOf(that.getSuppressed()));
 }
});
origin: seznam/euphoria

@Test
public void testSuppressedIOException() throws IOException {
 try {
  IOUtils.forEach(Arrays.asList(1, 2, 3), (i) -> {
   throw new IOException("Number: " + i);
  });
 } catch (Exception e) {
  assertEquals(2, e.getSuppressed().length); //two supressed exceptions and one thrown
  assertTrue(e instanceof IOException);
  assertEquals("Number: 1", e.getMessage());
 }
}
origin: fabric8io/kubernetes-client

Throwable[] suppressed = e.getSuppressed();
if (suppressed != null) {
  for (Throwable t : suppressed) {
java.langExceptiongetSuppressed

Popular methods of Exception

  • getMessage
  • printStackTrace
  • <init>
    Constructs a new exception with the specified cause and a detail message of (cause==null ? null : c
  • toString
  • getCause
  • getLocalizedMessage
  • getStackTrace
  • addSuppressed
  • initCause
  • fillInStackTrace
  • setStackTrace
  • logWithStack
  • setStackTrace,
  • logWithStack

Popular in Java

  • Creating JSON documents from java classes using gson
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setRequestProperty (URLConnection)
  • getExternalFilesDir (Context)
  • Kernel (java.awt.image)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Top Sublime Text 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