5

In the Undertow documentation, the following example is presented as a very simple server:

public class HelloWorldServer {

    public static void main(final String[] args) {
        Undertow server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(new HttpHandler() {
                    @Override
                    public void handleRequest(final HttpServerExchange exchange) throws Exception {
                        exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
                        exchange.getResponseSender().send("Hello World");
                    }
                }).build();
        server.start();
    }
}

How does this server shutdown? There is a server.stop() method that presumably would shutdown the server gracefully, but it is not used in this example. Should there be a shutdown hook associated with the runtime that would call the server.stop() method?

stepanian
  • 11,373
  • 8
  • 43
  • 63
  • Yes if you would like to shutdown the Server Gracefully you'll have to call the server.stop() Method else it will continue Running till its being interrupted. – Vishnu667 Nov 06 '15 at 07:54

0 Answers0