我有这段代码,它执行一些执行http调用的功能的并行执行,该功能位于从RestEeasy JAX-RS资源调用的@Singleton服务中
final Flowable<Map<String, List<Data>>> relatedMaps = Flowable.range(0, requestList.size())
concatMapEager(index ->
fetchByHttp(requestList.get(index))
.subscribeOn(Schedulers.io())
.toFlowable(),
requestList.size(),
1
);
其中fetchByHttp为:
Singe fetchByHttp(request) {
return Single.fromCallable( () -> {
...restClient.getData(request)
...
requestList.size()大约为100。
和有时,我遇到此问题:
14:28:35 ERROR [or.jb.re.re.i18n] (RxCachedThreadScheduler-232) RESTEASY002020: Unhandled asynchronous exception, sending back 500: java.lang.NullPointerException
at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:91)
at org.jboss.resteasy.core.AsyncResponseConsumer.sendBuiltResponse(AsyncResponseConsumer.java:148)
at org.jboss.resteasy.core.AsyncResponseConsumer.internalResume(AsyncResponseConsumer.java:115)
at org.jboss.resteasy.core.AsyncResponseConsumer$CompletionStageResponseConsumer.accept(AsyncResponseConsumer.java:237)
at org.jboss.resteasy.core.AsyncResponseConsumer$CompletionStageResponseConsumer.accept(AsyncResponseConsumer.java:216)
at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760)
at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:736)
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1962)
at io.reactivex.internal.observers.ConsumerSingleObserver.onSuccess(ConsumerSingleObserver.java:62)
at io.smallrye.context.propagators.rxjava2.ContextPropagatorOnSingleCreateAction$ContextCapturerSingle.lambda$onSuccess$2(ContextPropagatorOnSingleCreateAction.java:50)
at io.smallrye.context.SmallRyeThreadContext.lambda$withContext$0(SmallRyeThreadContext.java:215)
at io.smallrye.context.propagators.rxjava2.ContextPropagatorOnSingleCreateAction$ContextCapturerSingle.onSuccess(ContextPropagatorOnSingleCreateAction.java:50)
at io.smallrye.context.propagators.rxjava2.ContextPropagatorOnSingleCreateAction$ContextCapturerSingle.lambda$onSuccess$2(ContextPropagatorOnSingleCreateAction.java:50)
at io.smallrye.context.SmallRyeThreadContext.lambda$withContext$0(SmallRyeThreadContext.java:215)
在资源方面:
@Timeout(20000)
@GET
@Path("/data")
@Produces(MediaType.APPLICATION_JSON)
public CompletionStage<Data> getData(){
final Single<Data> dataSingle = service.getData();
final CompletableFuture<Data> dataFuture = new CompletableFuture<>();
dataSingle
//.subscribeOn(Schedulers.io())
.subscribe(dataFuture::complete);
return dataFuture;
}
找到了this。如果是固定的。然后问:发生了什么事以及如何处理?
Quarkus 1.0 Final。