wujimin commented on issue #2091:
URL:
https://github.com/apache/servicecomb-java-chassis/issues/2091#issuecomment-735520077
是的,新的Filter机制是将旧的各种扩展点全部归一化了,要实现的功能还是一样的
Filter的成员确实允许Autowire了
要切回eventloop,可以:
```java
VertxTransportContext transportContext = invocation.getTransportContext();
Executor executor =
VertxContextExecutor.create(transportContext.getVertxContext());
future.xxxAsync(xxx, executor)
.xxxxxx
```
xxx就在eventloop中执行了
要注意,future有个“特点”,下面用例中第二个apply不一定会在executor中执行,结果是由本线程与executor的真实执行顺序决定的,而这个顺序本身就是不确定的:
```java
@Test
@Disabled("用于证明jdk的CompletableFuture确实有问题,有较高概率出现,但是也不是必现;为防止CI概率性失败,改为手工执行")
void completable_future_thread_is_not_stable() {
for (int idx = 0; idx < LOOP_COUNT; idx++) {
CompletableFuture.completedFuture(null)
.thenApplyAsync(this::apply, executor)
.thenApply(this::apply)
.join();
}
assertThat(threadNames).containsExactlyInAnyOrder("main",
UT_THREAD_NAME);
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]