From 985640b6ceb24540e056d71423229cd54f32f1ac Mon Sep 17 00:00:00 2001 From: Stephane Maldini Date: Fri, 9 Oct 2015 16:25:02 +0100 Subject: [PATCH] Fix ReactorHttpServer with latest changes on shutdown behavior --- .../web/http/reactor/ReactorHttpServer.java | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/spring-web-reactive/src/main/java/org/springframework/reactive/web/http/reactor/ReactorHttpServer.java b/spring-web-reactive/src/main/java/org/springframework/reactive/web/http/reactor/ReactorHttpServer.java index a0c0c90237..76deb8ac29 100644 --- a/spring-web-reactive/src/main/java/org/springframework/reactive/web/http/reactor/ReactorHttpServer.java +++ b/spring-web-reactive/src/main/java/org/springframework/reactive/web/http/reactor/ReactorHttpServer.java @@ -13,21 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.reactive.web.http.reactor; +import reactor.bus.selector.Selectors; +import reactor.io.buffer.Buffer; +import reactor.io.net.NetStreams; + import org.springframework.beans.factory.InitializingBean; import org.springframework.reactive.web.http.HttpServer; import org.springframework.reactive.web.http.HttpServerSupport; import org.springframework.util.Assert; -import reactor.bus.selector.Selectors; -import reactor.io.buffer.Buffer; -import reactor.io.net.NetStreams; - /** * @author Stephane Maldini */ -public class ReactorHttpServer extends HttpServerSupport implements InitializingBean, HttpServer { +public class ReactorHttpServer extends HttpServerSupport + implements InitializingBean, HttpServer { private RequestHandlerAdapter reactorHandler; @@ -35,29 +37,27 @@ public class ReactorHttpServer extends HttpServerSupport implements Initializing private boolean running; - @Override public boolean isRunning() { return this.running; } - @Override public void afterPropertiesSet() throws Exception { Assert.notNull(getHttpHandler()); this.reactorHandler = new RequestHandlerAdapter(getHttpHandler()); - this.reactorServer = (getPort() != -1 ? - NetStreams.httpServer(getPort()) : NetStreams.httpServer()); + this.reactorServer = (getPort() != -1 ? NetStreams.httpServer(getPort()) : + NetStreams.httpServer()); } - @Override public void start() { if (!this.running) { try { - this.reactorServer.route(Selectors.matchAll(), this.reactorHandler).start().await(); + this.reactorServer.route(Selectors.matchAll(), this.reactorHandler) + .start().await(); this.running = true; } catch (InterruptedException ex) { @@ -69,13 +69,8 @@ public class ReactorHttpServer extends HttpServerSupport implements Initializing @Override public void stop() { if (this.running) { - try { - this.reactorServer.shutdown().await(); - this.running = false; - } - catch (InterruptedException ex) { - throw new IllegalStateException(ex); - } + this.reactorServer.shutdown(); + this.running = false; } }