DevModeHandler implements RequestHandler { public void stop() { if (atomicHandler.get() == null) { return; } try { prepareConnection("/stop", "GET").getResponseCode(); } catch (IOException e) { getLogger().debug( "webpack-dev-server does not support the `/stop` command.", e); } DevServerWatchDog watchDogInstance = watchDog.get(); if (watchDogInstance != null) { watchDogInstance.stop(); } Process process = webpackProcess.get(); if (process != null && process.isAlive()) { process.destroy(); } atomicHandler.set(null); removeRunningDevServerPort(); } private  DevModeHandler(DeploymentConfiguration config, int runningPort,
            File npmFolder, CompletableFuture<Void> waitFor); static DevModeHandler start(DeploymentConfiguration configuration,
            File npmFolder, CompletableFuture<Void> waitFor); static DevModeHandler start(int runningPort,
            DeploymentConfiguration configuration, File npmFolder,
            CompletableFuture<Void> waitFor); static DevModeHandler getDevModeHandler(); void setLiveReload(BrowserLiveReload liveReload); BrowserLiveReload getLiveReload(); @Override boolean handleRequest(VaadinSession session, VaadinRequest request,
            VaadinResponse response); boolean isDevModeRequest(HttpServletRequest request); boolean serveDevModeRequest(HttpServletRequest request,
            HttpServletResponse response); HttpURLConnection prepareConnection(String path, String method); String getFailedOutput(); void removeRunningDevServerPort(); int getPort(); boolean reuseDevServer(); void stop(); static final String WEBPACK_SERVER; }
@Test public void vaadinServlet_forDifferentRequests_shouldHaveCorrectResponse() throws Exception { HttpServletRequest request = prepareRequest("/VAADIN/foo.js"); HttpServletResponse response = prepareResponse(); int port = prepareHttpServer(0, HTTP_OK, ""); VaadinServlet servlet = prepareServlet(port); servlet.service(request, response); assertEquals(HTTP_OK, responseStatus); httpServer.stop(0); prepareHttpServer(port, HTTP_NOT_MODIFIED, ""); servlet.service(request, response); assertEquals(HTTP_NOT_MODIFIED, responseStatus); httpServer.stop(0); exception.expect(ConnectException.class); servlet.service(request, response); }