Java Code Examples for reactor.core.publisher.MonoProcessor#isTerminated()
The following examples show how to use
reactor.core.publisher.MonoProcessor#isTerminated() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyncInvocableHandlerMethod.java From spring-analysis-note with MIT License | 6 votes |
/** * Invoke the method for the given exchange. * @param exchange the current exchange * @param bindingContext the binding context to use * @param providedArgs optional list of argument values to match by type * @return a Mono with a {@link HandlerResult}. * @throws ServerErrorException if method argument resolution or method invocation fails */ @Nullable public HandlerResult invokeForHandlerResult(ServerWebExchange exchange, BindingContext bindingContext, Object... providedArgs) { MonoProcessor<HandlerResult> processor = MonoProcessor.create(); this.delegate.invoke(exchange, bindingContext, providedArgs).subscribeWith(processor); if (processor.isTerminated()) { Throwable ex = processor.getError(); if (ex != null) { throw (ex instanceof ServerErrorException ? (ServerErrorException) ex : new ServerErrorException("Failed to invoke: " + getShortLogMessage(), getMethod(), ex)); } return processor.peek(); } else { // Should never happen... throw new IllegalStateException( "SyncInvocableHandlerMethod should have completed synchronously."); } }
Example 2
Source File: SyncInvocableHandlerMethod.java From java-technology-stack with MIT License | 6 votes |
/** * Invoke the method for the given exchange. * @param exchange the current exchange * @param bindingContext the binding context to use * @param providedArgs optional list of argument values to match by type * @return a Mono with a {@link HandlerResult}. * @throws ServerErrorException if method argument resolution or method invocation fails */ @Nullable public HandlerResult invokeForHandlerResult(ServerWebExchange exchange, BindingContext bindingContext, Object... providedArgs) { MonoProcessor<HandlerResult> processor = MonoProcessor.create(); this.delegate.invoke(exchange, bindingContext, providedArgs).subscribeWith(processor); if (processor.isTerminated()) { Throwable ex = processor.getError(); if (ex != null) { throw (ex instanceof ServerErrorException ? (ServerErrorException) ex : new ServerErrorException("Failed to invoke: " + getShortLogMessage(), getMethod(), ex)); } return processor.peek(); } else { // Should never happen... throw new IllegalStateException( "SyncInvocableHandlerMethod should have completed synchronously."); } }
Example 3
Source File: ReactorNettyTcpClient.java From spring-analysis-note with MIT License | 5 votes |
private <T> Consumer<T> updateConnectMono(MonoProcessor<Void> connectMono) { return o -> { if (!connectMono.isTerminated()) { if (o instanceof Throwable) { connectMono.onError((Throwable) o); } else { connectMono.onComplete(); } } }; }
Example 4
Source File: ReactorNettyTcpClient.java From java-technology-stack with MIT License | 5 votes |
private <T> Consumer<T> updateConnectMono(MonoProcessor<Void> connectMono) { return o -> { if (!connectMono.isTerminated()) { if (o instanceof Throwable) { connectMono.onError((Throwable) o); } else { connectMono.onComplete(); } } }; }