java.lang.IllegalStateException.addSuppressed()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中java.lang.IllegalStateException.addSuppressed()方法的一些代码示例,展示了IllegalStateException.addSuppressed()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IllegalStateException.addSuppressed()方法的具体详情如下:
包路径:java.lang.IllegalStateException
类名称:IllegalStateException
方法名:addSuppressed

IllegalStateException.addSuppressed介绍

暂无

代码示例

代码示例来源:origin: google/guava

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

代码示例来源:origin: wildfly/wildfly

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

代码示例来源:origin: prestodb/presto

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

path = ShardPath.loadShardPath(logger, nodeEnv, shardId, this.indexSettings);
} catch (Exception inner) {
  ex.addSuppressed(inner);
  throw ex;

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql

@Override
public void close() throws ResourceException {
  if (managedConnection == null) {
    IllegalStateException error = new IllegalStateException("connection already closed " + this);
    error.addSuppressed(closeTrace);
    throw error;
  }
  try {
    managedConnection.close(this);
  } finally {
    closeTrace = new Throwable("close stack trace");
    managedConnection = null;
  }
}

代码示例来源:origin: org.apache.geronimo/geronimo-health

void stop(@Observes final BeforeShutdown beforeShutdown) {
  final IllegalStateException ise = new IllegalStateException("Something went wrong releasing health checks");
  contexts.forEach(c -> {
    try {
      c.release();
    } catch (final RuntimeException re) {
      ise.addSuppressed(re);
    }
  });
  final Throwable[] suppressed = ise.getSuppressed();
  if (suppressed.length == 1) {
    throw RuntimeException.class.cast(suppressed[0]);
  } else if (suppressed.length > 1) {
    throw ise;
  }
}

代码示例来源:origin: org.opendaylight.controller/sal-broker-impl

protected void closeSubtransactions() {
    /*
     * We share one exception for all failures, which are added
     * as supressedExceptions to it.
     */
    IllegalStateException failure = null;
    for (T subtransaction : backingTxs.values()) {
      try {
        subtransaction.close();
      } catch (Exception e) {
        // If we did not allocated failure we allocate it
        if (failure == null) {
          failure = new IllegalStateException("Uncaught exception occured during closing transaction", e);
        } else {
          // We update it with additional exceptions, which occurred during error.
          failure.addSuppressed(e);
        }
      }
    }
    // If we have failure, we throw it at after all attempts to close.
    if (failure != null) {
      throw failure;
    }
  }
}

代码示例来源:origin: hierynomus/smbj

private static MethodHandle getKrb5GetSessionKeyFunction() {
  Class<?> extendedContextClass;
  Class<?> inquireTypeClass;
  try {
    extendedContextClass = Class.forName("com.sun.security.jgss.ExtendedGSSContext", false, SpnegoAuthenticator.class.getClassLoader());
    inquireTypeClass = Class.forName("com.sun.security.jgss.InquireType");
  } catch (ClassNotFoundException e) {
    try {
      extendedContextClass = Class.forName("com.ibm.security.jgss.ExtendedGSSContext", false, SpnegoAuthenticator.class.getClassLoader());
      inquireTypeClass = Class.forName("com.ibm.security.jgss.InquireType");
    } catch (ClassNotFoundException e1) {
      IllegalStateException exception = new IllegalStateException("The code is running in an unknown java vm");
      exception.addSuppressed(e);
      exception.addSuppressed(e1);
      throw exception;
    }
  }
  @SuppressWarnings("unchecked")
  Object getSessionKeyConst = Enum.valueOf(inquireTypeClass.asSubclass(Enum.class), "KRB5_GET_SESSION_KEY");
  try {
    MethodHandle handle = MethodHandles.lookup().findVirtual(extendedContextClass, "inquireSecContext", MethodType.methodType(Object.class, inquireTypeClass));
    return MethodHandles.insertArguments(handle, 0, getSessionKeyConst).asType(MethodType.methodType(Key.class, GSSContext.class));
  } catch (NoSuchMethodException | IllegalAccessException e) {
    throw new IllegalStateException(e);
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore

protected void closeSubtransactions() {
  /*
   * We share one exception for all failures, which are added
   * as supressedExceptions to it.
   */
  IllegalStateException failure = null;
  for (T subtransaction : backingTxs.values()) {
    try {
      subtransaction.close();
    } catch (Exception e) {
      // If we did not allocated failure we allocate it
      if (failure == null) {
        failure = new IllegalStateException("Uncaught exception occured during closing transaction", e);
      } else {
        // We update it with additional exceptions, which occurred during error.
        failure.addSuppressed(e);
      }
    }
  }
  // If we have failure, we throw it at after all attempts to close.
  if (failure != null) {
    throw failure;
  }
}

代码示例来源:origin: org.openjdk.jcstress/jcstress-core

private static void initAndTest() {
  WhiteBox.registerNatives();
  WhiteBox w = new WhiteBox();
  Throwable deoptMethod = null;
  try {
    w.deoptimizeMethod(WhiteBoxSupport.class.getMethod("initSafely"));
    w.isClassAlive(WhiteBoxSupport.class.getName());
  } catch (Throwable ex) {
    deoptMethod = ex;
  }
  Throwable deoptAll = null;
  try {
    w.deoptimizeAll();
  } catch (Throwable ex) {
    deoptAll = ex;
  }
  if (deoptMethod == null) {
    mode = Mode.DEOPT_METHOD;
  } else if (deoptAll == null) {
    mode = Mode.DEOPT_ALL;
  } else {
    IllegalStateException whiteBoxFailed = new IllegalStateException();
    whiteBoxFailed.addSuppressed(deoptAll);
    whiteBoxFailed.addSuppressed(deoptMethod);
    throw whiteBoxFailed;
  }
  whiteBox = w;
}

代码示例来源:origin: GeoWebCache/geowebcache

deletedLayers.forEach(this::addLayer);
} catch (RuntimeException exceptionOnRestore) {
  wrappedException.addSuppressed(exceptionOnRestore);

代码示例来源:origin: org.testifyproject.external/external-guava

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

代码示例来源:origin: prestosql/presto

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

代码示例来源:origin: org.weakref/jmxutils

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

代码示例来源:origin: org.apache.ratis/ratis-proto-shaded

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

代码示例来源:origin: io.prestosql/presto-jdbc

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

代码示例来源:origin: martint/jmxutils

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

代码示例来源:origin: com.facebook.presto/presto-jdbc

@GuardedBy("monitor")
 void checkHealthy() {
  if (states.count(RUNNING) != numberOfServices) {
   IllegalStateException exception =
     new IllegalStateException(
       "Expected to be healthy after starting. The following services are not running: "
         + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
   for (Service service : servicesByState.get(State.FAILED)) {
    exception.addSuppressed(new FailedService(service));
   }
   throw exception;
  }
 }
}

相关文章