reactor.core.publisher.Hooks.resetOnOperatorError()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(145)

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

Hooks.resetOnOperatorError介绍

[英]Reset global operator error mapping to the default behavior.

For reference, the default mapping is to unwrap the exception and, if the second parameter is another exception, to add it to the first as a suppressed.
[中]将全局运算符错误映射重置为默认行为。
作为参考,默认映射是展开异常,如果第二个参数是另一个异常,则将其添加到第一个异常中作为抑制的。

代码示例

代码示例来源:origin: reactor/reactor-core

public void unplugHooks() {
  Hooks.resetOnNextDropped();
  Hooks.resetOnErrorDropped();
  Hooks.resetOnOperatorError();
}

代码示例来源:origin: reactor/reactor-core

@After
public void after() {
  Hooks.resetOnOperatorError();
}

代码示例来源:origin: reactor/reactor-core

@After
public void tearDown() {
  scheduler.dispose();
  Hooks.resetOnNextDropped();
  Hooks.resetOnErrorDropped();
  Hooks.resetOnOperatorError();
  Schedulers.resetOnHandleError();
  onNexts.clear();
  onErrors.clear();
  onNextDropped.clear();
  onErrorDropped.clear();
  onOperatorError.clear();
  onOperatorErrorData.clear();
  onSchedulerHandleError.clear();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void onOperatorErrorResetSpecific() {
  List<String> applied = new ArrayList<>(3);
  BiFunction<Throwable, Object, Throwable> hook1 = (t, s) -> {
    applied.add("h1");
    return t;
  };
  BiFunction<Throwable, Object, Throwable> hook2 = (t, s) -> {
    applied.add("h2");
    return t;
  };
  Hooks.onOperatorError("1", hook1);
  Hooks.onOperatorError(hook2);
  Hooks.onOperatorErrorHook.apply(new IllegalStateException("boom"), "foo");
  assertThat(Hooks.getOnOperatorErrorHooks()).hasSize(2);
  assertThat(applied).containsExactly("h1", "h2");
  applied.clear();
  Hooks.resetOnOperatorError("1");
  Hooks.onOperatorErrorHook.apply(new IllegalStateException("boom2"), "bar");
  assertThat(Hooks.getOnOperatorErrorHooks()).hasSize(1);
  assertThat(applied).containsExactly("h2");
}

代码示例来源:origin: reactor/reactor-core

@Test
public void onOperatorErrorReset() {
  Hooks.onOperatorError("some", (t, v) -> t);
  assertThat(Hooks.onOperatorErrorHook).isNotNull();
  assertThat(Hooks.getOnOperatorErrorHooks()).hasSize(1);
  Hooks.resetOnOperatorError();
  assertThat(Hooks.onOperatorErrorHook).isNull();
  assertThat(Hooks.getOnOperatorErrorHooks()).isEmpty();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void onOperatorErrorClearByName() {
  Hooks.onOperatorError("some", (t, v) -> t);
  Hooks.onOperatorError("other", (t, v) -> t);
  assertThat(Hooks.onOperatorErrorHook).isNotNull();
  assertThat(Hooks.getOnOperatorErrorHooks()).hasSize(2);
  Hooks.resetOnOperatorError("some");
  assertThat(Hooks.onOperatorErrorHook).isNotNull();
  assertThat(Hooks.getOnOperatorErrorHooks())
      .hasSize(1)
      .containsOnlyKeys("other");
  Hooks.resetOnOperatorError("other");
  assertThat(Hooks.onOperatorErrorHook).isNull();
  assertThat(Hooks.getOnOperatorErrorHooks()).isEmpty();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void onOperatorError() {
  AtomicReference<Object> errorValue = new AtomicReference<Object>();
  Hooks.onOperatorError((error, d) -> {
    errorValue.set(d);
    return error;
  });
  Flux<Integer> f1 = Mono.just(1).flatMapMany(i -> Flux.error(new Exception("test")));
  StepVerifier.create(f1).verifyErrorMessage("test");
  assertThat(errorValue.get()).isEqualTo(1);
  Flux<Integer> f2 = Mono.just(2).flatMapMany(i -> {
    throw new RuntimeException("test");
  });
  StepVerifier.create(f2).verifyErrorMessage("test");
  assertThat(errorValue.get()).isEqualTo(2);
  Flux<Integer> f3 = Flux.just(3, 6, 9).flatMap(i -> Flux.error(new Exception("test")));
  StepVerifier.create(f3).verifyErrorMessage("test");
  assertThat(errorValue.get()).isEqualTo(3);
  Flux<Integer> f4 = Flux.just(4, 8, 12).flatMap(i -> {
    throw new RuntimeException("test");
  });
  StepVerifier.create(f4).verifyErrorMessage("test");
  assertThat(errorValue.get()).isEqualTo(4);
  Hooks.resetOnOperatorError();
}

代码示例来源:origin: reactor/reactor-core

final void resetHooks() {
  Hooks.resetOnErrorDropped();
  Hooks.resetOnNextDropped();
  Hooks.resetOnEachOperator();
  Hooks.resetOnOperatorError();
  Hooks.resetOnLastOperator();
}

代码示例来源:origin: reactor/reactor-core

Hooks.resetOnOperatorError();

代码示例来源:origin: reactor/reactor-core

Hooks.resetOnOperatorError();

代码示例来源:origin: reactor/reactor-core

Hooks.resetOnOperatorError();

代码示例来源:origin: reactor/reactor-core

Hooks.resetOnOperatorError();

代码示例来源:origin: reactor/reactor-core

Hooks.resetOnOperatorError();

代码示例来源:origin: reactor/reactor-core

Hooks.resetOnOperatorError();

代码示例来源:origin: reactor/reactor-core

Hooks.resetOnOperatorError();

代码示例来源:origin: reactor/reactor-core

@After
public void resetAllHooks() {
  Hooks.resetOnOperatorError();
  Hooks.resetOnNextDropped();
  Hooks.resetOnErrorDropped();
  Hooks.resetOnOperatorDebug();
  Hooks.resetOnEachOperator();
  Hooks.resetOnLastOperator();
}

代码示例来源:origin: reactor/reactor-core

@After
public void resetAllHooks() {
  Hooks.resetOnOperatorError();
  Hooks.resetOnNextDropped();
  Hooks.resetOnErrorDropped();
  Hooks.resetOnOperatorDebug();
  Hooks.resetOnEachOperator();
  Hooks.resetOnLastOperator();
}

代码示例来源:origin: reactor/reactor-core

Hooks.resetOnOperatorError();

代码示例来源:origin: io.projectreactor/reactor-test

public void unplugHooks() {
  Hooks.resetOnNextDropped();
  Hooks.resetOnErrorDropped();
  Hooks.resetOnOperatorError();
}

相关文章