本文整理了Java中java.lang.IllegalArgumentException.getSuppressed()
方法的一些代码示例,展示了IllegalArgumentException.getSuppressed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IllegalArgumentException.getSuppressed()
方法的具体详情如下:
包路径:java.lang.IllegalArgumentException
类名称:IllegalArgumentException
方法名:getSuppressed
暂无
代码示例来源:origin: reactor/reactor-core
@Test
public void afterTerminateCallbackErrorAndErrorCallbackError() {
IllegalStateException err = new IllegalStateException("expected afterTerminate");
IllegalArgumentException err2 = new IllegalArgumentException("error");
FluxPeekFuseable<String> flux = new FluxPeekFuseable<>(
Flux.empty(), null, null, e -> { throw err2; },
null,
() -> { throw err; }, null, null);
AssertSubscriber<String> ts = AssertSubscriber.create();
try {
flux.subscribe(ts);
fail("expected thrown exception");
}
catch (Exception e) {
e.printStackTrace();
assertSame(e.toString(), err, e.getCause());
assertEquals(0, err2.getSuppressed().length);
//err2 is never thrown
}
ts.assertNoValues();
ts.assertComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void afterTerminateCallbackErrorAndErrorCallbackError() {
IllegalStateException err = new IllegalStateException("afterTerminate");
IllegalArgumentException err2 = new IllegalArgumentException("error");
FluxPeek<String> flux = new FluxPeek<>(Flux.empty(), null, null, e -> {
throw err2;
}, null, () -> {
throw err;
}, null, null);
AssertSubscriber<String> ts = AssertSubscriber.create();
try {
flux.subscribe(ts);
fail("expected thrown exception");
}
catch (Exception e) {
assertSame(err, e.getCause());
assertEquals(0, err2.getSuppressed().length);
//err2 is never thrown
}
ts.assertNoValues();
ts.assertComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void afterTerminateCallbackErrorAndErrorCallbackError2() {
IllegalStateException afterTerminate = new IllegalStateException("afterTerminate");
IllegalArgumentException error = new IllegalArgumentException("error");
NullPointerException err = new NullPointerException();
FluxPeekFuseable<String> flux = new FluxPeekFuseable<>(
Flux.error(err),
null, null,
e -> { throw error; }, null, () -> { throw afterTerminate; },
null, null);
AssertSubscriber<String> ts = AssertSubscriber.create();
try {
flux.subscribe(ts);
fail("expected thrown exception");
}
catch (Exception e) {
assertSame(afterTerminate, e.getCause());
//afterTerminate suppressed error which itself suppressed original err
assertEquals(1, afterTerminate.getSuppressed().length);
assertEquals(error, afterTerminate.getSuppressed()[0]);
assertEquals(1, error.getSuppressed().length);
assertEquals(err, error.getSuppressed()[0]);
}
ts.assertNoValues();
//the subscriber still sees the 'error' message since actual.onError is called before the afterTerminate callback
ts.assertErrorMessage("error");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void afterTerminateCallbackErrorAndErrorCallbackError2() {
IllegalStateException afterTerminate =
new IllegalStateException("afterTerminate");
IllegalArgumentException error = new IllegalArgumentException("error");
NullPointerException err = new NullPointerException();
FluxPeek<String> flux = new FluxPeek<>(Flux.error(err), null, null, e -> {
throw error;
}, null, () -> {
throw afterTerminate;
}, null, null);
AssertSubscriber<String> ts = AssertSubscriber.create();
try {
flux.subscribe(ts);
fail("expected thrown exception");
}
catch (Exception e) {
assertSame(afterTerminate, e.getCause());
//afterTerminate suppressed error which itself suppressed original err
assertEquals(1, afterTerminate.getSuppressed().length);
assertEquals(error, afterTerminate.getSuppressed()[0]);
assertEquals(1, error.getSuppressed().length);
assertEquals(err, error.getSuppressed()[0]);
}
ts.assertNoValues();
//the subscriber still sees the 'error' message since actual.onError is called before the afterTerminate callback
ts.assertErrorMessage("error");
}
代码示例来源:origin: org.elasticsearch/elasticsearch
} catch (IllegalArgumentException iae) {
validationErrors.add(iae.getMessage());
for (Throwable t : iae.getSuppressed()) {
validationErrors.add(t.getMessage());
代码示例来源:origin: palatable/lambda
@Test
public void exceptionThrownInEnsuringBlockIsCaught() {
IllegalStateException expected = new IllegalStateException();
assertEquals(Try.failure(expected), Try.success(1).ensuring(() -> {throw expected;}));
Either<IllegalArgumentException, Object> actual = Try.failure(new IllegalArgumentException())
.ensuring(() -> { throw expected;})
.toEither();
assertThat(actual, isLeftThat(instanceOf(IllegalArgumentException.class)));
assertEquals(left(expected), actual.biMapL(t -> t.getSuppressed()[0]));
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
} catch (IllegalArgumentException iae) {
validationErrors.add(iae.getMessage());
for (Throwable t : iae.getSuppressed()) {
validationErrors.add(t.getMessage());
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
} catch (IllegalArgumentException iae) {
validationErrors.add(iae.getMessage());
for (Throwable t : iae.getSuppressed()) {
validationErrors.add(t.getMessage());
代码示例来源:origin: apache/servicemix-bundles
} catch (IllegalArgumentException iae) {
validationErrors.add(iae.getMessage());
for (Throwable t : iae.getSuppressed()) {
validationErrors.add(t.getMessage());
内容来源于网络,如有侵权,请联系作者删除!