Use PublisherFactory from reactor-core

This commit is contained in:
Rossen Stoyanchev
2015-08-17 16:52:39 -04:00
parent 773d0444bf
commit 69d4eaaa3c
3 changed files with 35 additions and 136 deletions
@@ -21,6 +21,8 @@ import java.util.List;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import reactor.core.reactivestreams.PublisherFactory;
import reactor.core.reactivestreams.SubscriberWithContext;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.context.ApplicationContext;
@@ -58,7 +60,7 @@ public class DispatcherHttpHandler implements HttpHandler {
if (handler == null) {
// No exception handling mechanism yet
response.setStatusCode(HttpStatus.NOT_FOUND);
return Publishers.complete();
return PublisherFactory.forEach(SubscriberWithContext::onComplete);
}
HandlerAdapter handlerAdapter = getHandlerAdapter(handler);
@@ -143,27 +145,4 @@ public class DispatcherHttpHandler implements HttpHandler {
throw new IllegalStateException("No HandlerAdapter for " + handler);
}
private static class Publishers {
public static Publisher<Void> complete() {
return subscriber -> {
subscriber.onSubscribe(new NoopSubscription());
subscriber.onComplete();
};
}
}
private static class NoopSubscription implements Subscription {
@Override
public void request(long n) {
}
@Override
public void cancel() {
}
}
}