--- old/test/jdk/java/net/httpclient/websocket/DummyWebSocketServer.java 2017-09-25 11:36:06.659846190 +0100 +++ new/test/jdk/java/net/httpclient/websocket/DummyWebSocketServer.java 2017-09-25 11:36:06.475846196 +0100 @@ -105,7 +105,7 @@ channel.configureBlocking(true); StringBuilder request = new StringBuilder(); if (!readRequest(channel, request)) { - throw new IOException("Bad request"); + throw new IOException("Bad request:" + request); } List strings = asList(request.toString().split("\r\n")); List response = mapping.apply(strings); @@ -156,6 +156,7 @@ public void close() { log.log(INFO, "Stopping: " + getURI()); thread.interrupt(); + close(ssc); } URI getURI() { @@ -169,19 +170,21 @@ throws IOException { ByteBuffer buffer = ByteBuffer.allocate(512); - int num = channel.read(buffer); - if (num == -1) { - return false; - } - CharBuffer decoded; - buffer.flip(); - try { - decoded = ISO_8859_1.newDecoder().decode(buffer); - } catch (CharacterCodingException e) { - throw new UncheckedIOException(e); + while (channel.read(buffer) != -1) { + // read the complete HTTP request headers, there should be no body + CharBuffer decoded; + buffer.flip(); + try { + decoded = ISO_8859_1.newDecoder().decode(buffer); + } catch (CharacterCodingException e) { + throw new UncheckedIOException(e); + } + request.append(decoded); + if (Pattern.compile("\r\n\r\n").matcher(request).find()) + return true; + buffer.clear(); } - request.append(decoded); - return Pattern.compile("\r\n\r\n").matcher(request).find(); + return false; } private void writeResponse(SocketChannel channel, List response) --- old/test/jdk/java/net/httpclient/websocket/LoggingHelper.java 2017-09-25 11:36:07.127846174 +0100 +++ new/test/jdk/java/net/httpclient/websocket/LoggingHelper.java 2017-09-25 11:36:06.943846180 +0100 @@ -32,7 +32,7 @@ * @run main/othervm/jul=logging.properties ClassUnderTest */ public static void setupLogging() { - String path = System.getProperty("test.src") + File.separator + "logging.properties"; + String path = System.getProperty("test.src", ".") + File.separator + "logging.properties"; System.setProperty("java.util.logging.config.file", path); } }