本文整理了Java中reactor.core.Exceptions.bubble()
方法的一些代码示例,展示了Exceptions.bubble()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Exceptions.bubble()
方法的具体详情如下:
包路径:reactor.core.Exceptions
类名称:Exceptions
方法名:bubble
[英]Prepare an unchecked RuntimeException that will bubble upstream if thrown by an operator.
This method invokes #throwIfFatal(Throwable).
[中]准备一个未检查的RuntimeException,如果由操作符抛出,它将冒泡到上游。
此方法调用#throwIfFatal(Throwable)。
代码示例来源:origin: reactor/reactor-core
protected final RuntimeException exception() {
if (defaultScenario.producerError == null) {
throw Exceptions.bubble(new Exception("No exception set in " + "defaultScenario"));
}
return defaultScenario.producerError;
}
代码示例来源:origin: reactor/reactor-core
int slow(int slow){
try {
Thread.sleep(10);
return slow;
}
catch (InterruptedException e) {
throw Exceptions.bubble(e);
}
}
代码示例来源:origin: reactor/reactor-core
protected final RuntimeException droppedException() {
if (defaultScenario.droppedError == null) {
throw Exceptions.bubble(new Exception("No dropped exception set in " + "defaultScenario"));
}
return defaultScenario.droppedError;
}
代码示例来源:origin: reactor/reactor-core
protected final I item(int i) {
if (defaultScenario.producingMapper == null) {
throw Exceptions.bubble(new Exception("No producer set in " + "defaultScenario"));
}
return defaultScenario.producingMapper
.apply(i);
}
代码示例来源:origin: reactor/reactor-core
/**
* An unexpected exception is about to be dropped.
* <p>
* If no hook is registered for {@link Hooks#onErrorDropped(Consumer)}, the dropped
* error is logged at ERROR level and thrown (via {@link Exceptions#bubble(Throwable)}.
*
* @param e the dropped exception
* @param context a context that might hold a local error consumer
*/
public static void onErrorDropped(Throwable e, Context context) {
Consumer<? super Throwable> hook = context.getOrDefault(Hooks.KEY_ON_ERROR_DROPPED,null);
if (hook == null) {
hook = Hooks.onErrorDroppedHook;
}
if (hook == null) {
log.error("Operator called default onErrorDropped", e);
throw Exceptions.bubble(e);
}
hook.accept(e);
}
代码示例来源:origin: reactor/reactor-core
Exceptions.bubble(e);
throw Exceptions.bubble(e);
代码示例来源:origin: reactor/reactor-core
int slow(int slow){
try {
execs.computeIfAbsent(Thread.currentThread()
.hashCode(), i -> 0);
execs.compute(Thread.currentThread()
.hashCode(), (k, v) -> v + 1);
Thread.sleep(10);
return slow;
}
catch (InterruptedException e) {
throw Exceptions.bubble(e);
}
}
代码示例来源:origin: reactor/reactor-core
e.addSuppressed(scenario.stack);
throw Exceptions.bubble(e);
代码示例来源:origin: reactor/reactor-core
@Test
public void testNullWrapping() throws Exception {
Throwable w = Exceptions.bubble(null);
assertTrue(Exceptions.unwrap(w) == w);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void testWrapping() throws Exception {
Throwable t = new Exception("test");
Throwable w = Exceptions.bubble(Exceptions.propagate(t));
assertTrue(Exceptions.unwrap(w) == t);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void consumerBubbleError() {
LongAdder state = new LongAdder();
Throwable err = new Exception("test");
assertThatThrownBy(() ->
StepVerifier.create(
Mono.just(1)
.doOnEach(s -> {
if (s.isOnNext()) {
state.increment();
throw Exceptions.bubble(err);
}
}))
.expectErrorMessage("test")
.verify())
.isInstanceOf(RuntimeException.class)
.matches(Exceptions::isBubbling, "bubbling")
.hasCause(err); //equivalent to unwrap for this case
assertThat(state.intValue()).isEqualTo(1);
}
代码示例来源:origin: reactor/reactor-core
@Test
@Parameters(method = "sources12Complete")
public void nextCallbackBubbleError(Flux<Integer> source) {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
LongAdder state = new LongAdder();
Throwable err = new Exception("test");
try {
source
.doOnEach(s -> {
if (s.isOnNext()) {
state.increment();
throw Exceptions.bubble(err);
}
})
.filter(t -> true)
.subscribe(ts);
fail();
}
catch (Exception e) {
Assert.assertTrue(Exceptions.unwrap(e) == err);
Assert.assertEquals(1, state.intValue());
}
}
代码示例来源:origin: reactor/reactor-core
})
.doOnError(d -> {
throw Exceptions.bubble(err);
})
.subscribe(ts);
代码示例来源:origin: reactor/reactor-core
throw Exceptions.bubble(e1);
代码示例来源:origin: reactor/reactor-core
})
.doOnError(d -> {
throw Exceptions.bubble(err);
})
.subscribe(ts);
代码示例来源:origin: reactor/reactor-core
@Test
public void completeCallbackError() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Throwable err = new Exception("test");
Flux.just(1)
.doOnComplete(() -> {
throw Exceptions.propagate(err);
})
.subscribe(ts);
//nominal error path (DownstreamException)
ts.assertErrorMessage("test");
ts = AssertSubscriber.create();
try {
Flux.just(1)
.doOnComplete(() -> {
throw Exceptions.bubble(err);
})
.subscribe(ts);
Assert.fail();
}
catch (Exception e) {
Assert.assertTrue(Exceptions.unwrap(e) == err);
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void callbackError() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Throwable err = new Exception("test");
Flux.just(1)
.doOnNext(d -> {
throw Exceptions.propagate(err);
})
.subscribe(ts);
//nominal error path (DownstreamException)
ts.assertErrorMessage("test");
ts = AssertSubscriber.create();
try {
Flux.just(1)
.doOnNext(d -> {
throw Exceptions.bubble(err);
})
.subscribe(ts);
Assert.fail();
}
catch (Exception e) {
Assert.assertTrue(Exceptions.unwrap(e) == err);
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void callbackError() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Throwable err = new Exception("test");
Flux.just(1)
.hide()
.doOnNext(d -> {
throw Exceptions.propagate(err);
})
.subscribe(ts);
//nominal error path (DownstreamException)
ts.assertErrorMessage("test");
ts = AssertSubscriber.create();
try {
Flux.just(1)
.hide()
.doOnNext(d -> {
throw Exceptions.bubble(err);
})
.subscribe(ts);
fail();
}
catch (Exception e) {
Assert.assertTrue(Exceptions.unwrap(e) == err);
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void completeCallbackError() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Throwable err = new Exception("test");
Flux.just(1)
.hide()
.doOnComplete(() -> {
throw Exceptions.propagate(err);
})
.subscribe(ts);
//nominal error path (DownstreamException)
ts.assertErrorMessage("test");
ts = AssertSubscriber.create();
try {
Flux.just(1)
.hide()
.doOnComplete(() -> {
throw Exceptions.bubble(err);
})
.subscribe(ts);
fail();
}
catch (Exception e) {
Assert.assertTrue(Exceptions.unwrap(e) == err);
}
}
代码示例来源:origin: mulesoft/mule
@Test
public void errorsStream() throws Exception {
flow = flowBuilder.get().processors(failingProcessor).build();
flow.initialise();
flow.start();
CountDownLatch latch = new CountDownLatch(STREAM_ITERATIONS);
for (int i = 0; i < STREAM_ITERATIONS; i++) {
dispatchFlow(newEvent(), response -> bubble(new AssertionError("Unexpected success")), t -> latch.countDown());
}
assertThat(latch.await(RECEIVE_TIMEOUT, MILLISECONDS), is(true));
}
内容来源于网络,如有侵权,请联系作者删除!