Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2014-05-09 17:36:25 +0000
committerJoakim Erdfelt2014-05-09 17:36:25 +0000
commit88a1512d44046542426a860115240dd542a8ff2c (patch)
tree4759f94b776036c793e982c7159bdd2b6c366ac6 /jetty-websocket/websocket-api/src
parentb7b29ca4a3c53b4a0367f771ae595e94332b2ee7 (diff)
downloadorg.eclipse.jetty.project-88a1512d44046542426a860115240dd542a8ff2c.tar.gz
org.eclipse.jetty.project-88a1512d44046542426a860115240dd542a8ff2c.tar.xz
org.eclipse.jetty.project-88a1512d44046542426a860115240dd542a8ff2c.zip
431333 - NPE In logging of WebSocket ExtensionConfig
+ Fixed NPE
Diffstat (limited to 'jetty-websocket/websocket-api/src')
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/QuoteUtil.java8
-rw-r--r--jetty-websocket/websocket-api/src/test/java/org/eclipse/jetty/websocket/api/util/QuoteUtilTest.java19
2 files changed, 26 insertions, 1 deletions
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/QuoteUtil.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/QuoteUtil.java
index bf9c2fc9c2..59c0177a20 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/QuoteUtil.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/QuoteUtil.java
@@ -345,8 +345,16 @@ public class QuoteUtil
*/
public static void quoteIfNeeded(StringBuilder buf, String str, String delim)
{
+ if (str == null)
+ {
+ return;
+ }
// check for delimiters in input string
int len = str.length();
+ if (len == 0)
+ {
+ return;
+ }
int ch;
for (int i = 0; i < len; i++)
{
diff --git a/jetty-websocket/websocket-api/src/test/java/org/eclipse/jetty/websocket/api/util/QuoteUtilTest.java b/jetty-websocket/websocket-api/src/test/java/org/eclipse/jetty/websocket/api/util/QuoteUtilTest.java
index 9d70d21ee0..9fd0db4b5d 100644
--- a/jetty-websocket/websocket-api/src/test/java/org/eclipse/jetty/websocket/api/util/QuoteUtilTest.java
+++ b/jetty-websocket/websocket-api/src/test/java/org/eclipse/jetty/websocket/api/util/QuoteUtilTest.java
@@ -18,7 +18,8 @@
package org.eclipse.jetty.websocket.api.util;
-import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
import java.util.Iterator;
import java.util.NoSuchElementException;
@@ -136,4 +137,20 @@ public class QuoteUtilTest
Iterator<String> iter = QuoteUtil.splitAt("Key = Value","=");
assertSplitAt(iter,"Key","Value");
}
+
+ @Test
+ public void testQuoteIfNeeded()
+ {
+ StringBuilder buf = new StringBuilder();
+ QuoteUtil.quoteIfNeeded(buf, "key",",");
+ assertThat("key",buf.toString(),is("key"));
+ }
+
+ @Test
+ public void testQuoteIfNeeded_null()
+ {
+ StringBuilder buf = new StringBuilder();
+ QuoteUtil.quoteIfNeeded(buf, null,";=");
+ assertThat("<null>",buf.toString(),is(""));
+ }
}

Back to the top