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

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

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

IllegalStateException.addSuppressed介绍

暂无

代码示例

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

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

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

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

  1. @Override
  2. public void close() throws ResourceException {
  3. if (managedConnection == null) {
  4. IllegalStateException error = new IllegalStateException("connection already closed " + this);
  5. error.addSuppressed(closeTrace);
  6. throw error;
  7. }
  8. try {
  9. managedConnection.close(this);
  10. } finally {
  11. closeTrace = new Throwable("close stack trace");
  12. managedConnection = null;
  13. }
  14. }

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

  1. void stop(@Observes final BeforeShutdown beforeShutdown) {
  2. final IllegalStateException ise = new IllegalStateException("Something went wrong releasing health checks");
  3. contexts.forEach(c -> {
  4. try {
  5. c.release();
  6. } catch (final RuntimeException re) {
  7. ise.addSuppressed(re);
  8. }
  9. });
  10. final Throwable[] suppressed = ise.getSuppressed();
  11. if (suppressed.length == 1) {
  12. throw RuntimeException.class.cast(suppressed[0]);
  13. } else if (suppressed.length > 1) {
  14. throw ise;
  15. }
  16. }

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

  1. protected void closeSubtransactions() {
  2. /*
  3. * We share one exception for all failures, which are added
  4. * as supressedExceptions to it.
  5. */
  6. IllegalStateException failure = null;
  7. for (T subtransaction : backingTxs.values()) {
  8. try {
  9. subtransaction.close();
  10. } catch (Exception e) {
  11. // If we did not allocated failure we allocate it
  12. if (failure == null) {
  13. failure = new IllegalStateException("Uncaught exception occured during closing transaction", e);
  14. } else {
  15. // We update it with additional exceptions, which occurred during error.
  16. failure.addSuppressed(e);
  17. }
  18. }
  19. }
  20. // If we have failure, we throw it at after all attempts to close.
  21. if (failure != null) {
  22. throw failure;
  23. }
  24. }
  25. }

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

  1. private static MethodHandle getKrb5GetSessionKeyFunction() {
  2. Class<?> extendedContextClass;
  3. Class<?> inquireTypeClass;
  4. try {
  5. extendedContextClass = Class.forName("com.sun.security.jgss.ExtendedGSSContext", false, SpnegoAuthenticator.class.getClassLoader());
  6. inquireTypeClass = Class.forName("com.sun.security.jgss.InquireType");
  7. } catch (ClassNotFoundException e) {
  8. try {
  9. extendedContextClass = Class.forName("com.ibm.security.jgss.ExtendedGSSContext", false, SpnegoAuthenticator.class.getClassLoader());
  10. inquireTypeClass = Class.forName("com.ibm.security.jgss.InquireType");
  11. } catch (ClassNotFoundException e1) {
  12. IllegalStateException exception = new IllegalStateException("The code is running in an unknown java vm");
  13. exception.addSuppressed(e);
  14. exception.addSuppressed(e1);
  15. throw exception;
  16. }
  17. }
  18. @SuppressWarnings("unchecked")
  19. Object getSessionKeyConst = Enum.valueOf(inquireTypeClass.asSubclass(Enum.class), "KRB5_GET_SESSION_KEY");
  20. try {
  21. MethodHandle handle = MethodHandles.lookup().findVirtual(extendedContextClass, "inquireSecContext", MethodType.methodType(Object.class, inquireTypeClass));
  22. return MethodHandles.insertArguments(handle, 0, getSessionKeyConst).asType(MethodType.methodType(Key.class, GSSContext.class));
  23. } catch (NoSuchMethodException | IllegalAccessException e) {
  24. throw new IllegalStateException(e);
  25. }
  26. }

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

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

  1. protected void closeSubtransactions() {
  2. /*
  3. * We share one exception for all failures, which are added
  4. * as supressedExceptions to it.
  5. */
  6. IllegalStateException failure = null;
  7. for (T subtransaction : backingTxs.values()) {
  8. try {
  9. subtransaction.close();
  10. } catch (Exception e) {
  11. // If we did not allocated failure we allocate it
  12. if (failure == null) {
  13. failure = new IllegalStateException("Uncaught exception occured during closing transaction", e);
  14. } else {
  15. // We update it with additional exceptions, which occurred during error.
  16. failure.addSuppressed(e);
  17. }
  18. }
  19. }
  20. // If we have failure, we throw it at after all attempts to close.
  21. if (failure != null) {
  22. throw failure;
  23. }
  24. }

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

  1. private static void initAndTest() {
  2. WhiteBox.registerNatives();
  3. WhiteBox w = new WhiteBox();
  4. Throwable deoptMethod = null;
  5. try {
  6. w.deoptimizeMethod(WhiteBoxSupport.class.getMethod("initSafely"));
  7. w.isClassAlive(WhiteBoxSupport.class.getName());
  8. } catch (Throwable ex) {
  9. deoptMethod = ex;
  10. }
  11. Throwable deoptAll = null;
  12. try {
  13. w.deoptimizeAll();
  14. } catch (Throwable ex) {
  15. deoptAll = ex;
  16. }
  17. if (deoptMethod == null) {
  18. mode = Mode.DEOPT_METHOD;
  19. } else if (deoptAll == null) {
  20. mode = Mode.DEOPT_ALL;
  21. } else {
  22. IllegalStateException whiteBoxFailed = new IllegalStateException();
  23. whiteBoxFailed.addSuppressed(deoptAll);
  24. whiteBoxFailed.addSuppressed(deoptMethod);
  25. throw whiteBoxFailed;
  26. }
  27. whiteBox = w;
  28. }

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

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

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

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

  1. @GuardedBy("monitor")
  2. void checkHealthy() {
  3. if (states.count(RUNNING) != numberOfServices) {
  4. IllegalStateException exception =
  5. new IllegalStateException(
  6. "Expected to be healthy after starting. The following services are not running: "
  7. + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING))));
  8. for (Service service : servicesByState.get(State.FAILED)) {
  9. exception.addSuppressed(new FailedService(service));
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

相关文章