diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java index c641fd682de..39f0fa918ec 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/StdErrLog.java @@ -31,12 +31,11 @@ import org.eclipse.jetty.util.DateCache; * the eclipse jetty root level logger level to that specified level. (Default level is INFO) *

* If the system property "org.eclipse.jetty.util.log.SOURCE" is set, then the source method/file of a log is logged. - * For named debuggers, the system property name+".SOURCE" is checked. If it is not not set, then - * "org.eclipse.jetty.util.log.SOURCE" is used as the default. + * For named debuggers, the system property name+".SOURCE" is checked, eg "org.eclipse.jetty.util.log.stderr.SOURCE". + * If it is not not set, then "org.eclipse.jetty.util.log.SOURCE" is used as the default. *

- * If the system property "org.eclipse.jetty.util.log.LONG" is set, then the full, unabbreviated name of the logger is - * used for logging. For named debuggers, the system property name+".LONG" is checked. If it is not not set, then - * "org.eclipse.jetty.util.log.LONG" is used as the default. + * If the system property "org.eclipse.jetty.util.log.stderr.LONG" is set, then the full, unabbreviated name of the logger is + * used for logging. */ public class StdErrLog extends AbstractLogger { diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java index 5ef50cafad6..8296b1a9b2c 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/WebSocketServletRFCTest.java @@ -80,6 +80,8 @@ public class WebSocketServletRFCTest try { conn.sendMessage(data); + + conn.close(1000, data); } catch (IOException e) { @@ -240,4 +242,44 @@ public class WebSocketServletRFCTest sender.close(); } } + + /** + * Test the requirement of responding with server terminated close code 1011 when there is an unhandled (internal + * server error) being produced by the extended WebSocketServlet. + */ + @Test + public void testResponseOfHttpKeyword() throws Exception + { + WebSocketClientFactory clientFactory = new WebSocketClientFactory(); + clientFactory.start(); + + WebSocketClient wsc = clientFactory.newWebSocketClient(); + MessageSender sender = new MessageSender(); + wsc.open(serverUri,sender); + + String message = "GET"; + + try + { + sender.awaitConnect(); + + // echo back a http keyword + sender.sendMessage(message); + + // Give servlet 500 millisecond to process messages + TimeUnit.MILLISECONDS.sleep(500); + + sender.awaitMessage(); + + Assert.assertEquals("Message should match",message, sender.getMessage()); + Assert.assertThat("WebSocket should be closed",sender.isConnected(),is(false)); + Assert.assertThat("WebSocket close clode",sender.getCloseCode(),is(1000)); + Assert.assertEquals("WebSocket close message",message, sender.getCloseMessage()); + + } + finally + { + sender.close(); + } + } } diff --git a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java index 8b3e5779911..ecff608bc23 100644 --- a/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java +++ b/jetty-websocket/src/test/java/org/eclipse/jetty/websocket/helper/MessageSender.java @@ -24,13 +24,17 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.websocket.WebSocket; -public class MessageSender implements WebSocket +public class MessageSender implements WebSocket, WebSocket.OnTextMessage { private Connection conn; private CountDownLatch connectLatch = new CountDownLatch(1); + private CountDownLatch messageLatch = new CountDownLatch(1); + private int closeCode = -1; private String closeMessage = null; - + private String message = null; + + public void onOpen(Connection connection) { this.conn = connection; @@ -43,6 +47,12 @@ public class MessageSender implements WebSocket this.closeCode = closeCode; this.closeMessage = message; } + + + public void onMessage(String data) + { + message = data; + } public boolean isConnected() { @@ -62,6 +72,11 @@ public class MessageSender implements WebSocket { return closeMessage; } + + public String getMessage() + { + return message; + } public void sendMessage(String format, Object... args) throws IOException { @@ -72,6 +87,11 @@ public class MessageSender implements WebSocket { connectLatch.await(1,TimeUnit.SECONDS); } + + public void awaitMessage() throws InterruptedException + { + messageLatch.await(1,TimeUnit.SECONDS); + } public void close() {