Replace Promises.error->Streams.fail, concatMap->map
This commit is contained in:
parent
6634d1f536
commit
56d6940485
|
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.reactivestreams.PublisherFactory;
|
||||
import reactor.core.reactivestreams.SubscriberWithContext;
|
||||
import reactor.rx.Promises;
|
||||
import reactor.rx.Streams;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
|
|
@ -72,8 +71,8 @@ public class DispatcherHttpHandler implements HttpHandler {
|
|||
return resultHandler.handleResult(request, response, result);
|
||||
}
|
||||
}
|
||||
String error = "No HandlerResultHandler for " + result.getReturnValue();
|
||||
return Promises.error(new IllegalStateException(error));
|
||||
return Streams.fail(new IllegalStateException(
|
||||
"No HandlerResultHandler for " + result.getReturnValue()));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import java.util.Map;
|
|||
import io.netty.buffer.ByteBuf;
|
||||
import io.reactivex.netty.protocol.http.server.HttpServer;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.rx.Stream;
|
||||
import reactor.rx.Streams;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
|
|
@ -93,9 +92,8 @@ public class DispatcherApp {
|
|||
|
||||
@Override
|
||||
public Publisher<HandlerResult> handle(ServerHttpRequest request, ServerHttpResponse response, Object handler) {
|
||||
Publisher<String> resultPublisher = ((PlainTextHandler) handler).handle(request, response);
|
||||
Stream<String> stream = Streams.wrap(resultPublisher);
|
||||
return stream.concatMap((returnValue) -> Streams.just(new HandlerResult(returnValue)));
|
||||
Publisher<String> publisher = ((PlainTextHandler) handler).handle(request, response);
|
||||
return Streams.wrap(publisher).map(HandlerResult::new);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue