From cb42ffc706cb183d7958a9c3fdea63310d0dbedf Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 13 Jul 2016 15:23:46 +1000 Subject: [PATCH 1/2] improved test timeouts --- .../http2/alpn/tests/ALPNNegotiationTest.java | 2 +- .../jetty/http2/client/IdleTimeoutTest.java | 20 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/jetty-http2/http2-alpn-tests/src/test/java/org/eclipse/jetty/http2/alpn/tests/ALPNNegotiationTest.java b/jetty-http2/http2-alpn-tests/src/test/java/org/eclipse/jetty/http2/alpn/tests/ALPNNegotiationTest.java index 1cafaed344a..ec1421c6e1d 100644 --- a/jetty-http2/http2-alpn-tests/src/test/java/org/eclipse/jetty/http2/alpn/tests/ALPNNegotiationTest.java +++ b/jetty-http2/http2-alpn-tests/src/test/java/org/eclipse/jetty/http2/alpn/tests/ALPNNegotiationTest.java @@ -30,8 +30,8 @@ import java.util.Arrays; import java.util.List; import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLEngine; import org.eclipse.jetty.alpn.ALPN; import org.eclipse.jetty.util.BufferUtil; diff --git a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java index acf889223f5..c2e8188445c 100644 --- a/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java +++ b/jetty-http2/http2-client/src/test/java/org/eclipse/jetty/http2/client/IdleTimeoutTest.java @@ -94,9 +94,7 @@ public class IdleTimeoutTest extends AbstractTest } }, new Stream.Listener.Adapter()); - Assert.assertTrue(latch.await(2 * idleTimeout, TimeUnit.MILLISECONDS)); - - sleep(1000); + Assert.assertTrue(latch.await(5 * idleTimeout, TimeUnit.MILLISECONDS)); } @Test @@ -136,7 +134,7 @@ public class IdleTimeoutTest extends AbstractTest } }, new Stream.Listener.Adapter()); - Assert.assertTrue(latch.await(2 * idleTimeout, TimeUnit.MILLISECONDS)); + Assert.assertTrue(latch.await(5 * idleTimeout, TimeUnit.MILLISECONDS)); } @Test @@ -190,7 +188,7 @@ public class IdleTimeoutTest extends AbstractTest } }); - Assert.assertTrue(replyLatch.await(3 * idleTimeout, TimeUnit.MILLISECONDS)); + Assert.assertTrue(replyLatch.await(5 * idleTimeout, TimeUnit.MILLISECONDS)); // Just make sure onClose() has never been called, but don't wait too much Assert.assertFalse(closeLatch.await(idleTimeout / 2, TimeUnit.MILLISECONDS)); @@ -233,7 +231,7 @@ public class IdleTimeoutTest extends AbstractTest } }, new Stream.Listener.Adapter()); - Assert.assertTrue(closeLatch.await(2 * idleTimeout, TimeUnit.MILLISECONDS)); + Assert.assertTrue(closeLatch.await(5 * idleTimeout, TimeUnit.MILLISECONDS)); Assert.assertTrue(session.isClosed()); } @@ -271,7 +269,7 @@ public class IdleTimeoutTest extends AbstractTest } }, new Stream.Listener.Adapter()); - Assert.assertTrue(closeLatch.await(2 * idleTimeout, TimeUnit.MILLISECONDS)); + Assert.assertTrue(closeLatch.await(5 * idleTimeout, TimeUnit.MILLISECONDS)); } @Test @@ -324,7 +322,7 @@ public class IdleTimeoutTest extends AbstractTest }); Assert.assertFalse(closeLatch.await(2 * idleTimeout, TimeUnit.MILLISECONDS)); - Assert.assertTrue(replyLatch.await(3 * idleTimeout, TimeUnit.MILLISECONDS)); + Assert.assertTrue(replyLatch.await(5 * idleTimeout, TimeUnit.MILLISECONDS)); } @Test @@ -474,8 +472,8 @@ public class IdleTimeoutTest extends AbstractTest } }); - Assert.assertTrue(dataLatch.await(2 * idleTimeout, TimeUnit.MILLISECONDS)); - Assert.assertFalse(timeoutLatch.await(0, TimeUnit.SECONDS)); + Assert.assertTrue(dataLatch.await(5 * idleTimeout, TimeUnit.MILLISECONDS)); + Assert.assertFalse(timeoutLatch.await(1, TimeUnit.SECONDS)); } @Test @@ -521,7 +519,7 @@ public class IdleTimeoutTest extends AbstractTest sleep(idleTimeout / 2); stream.data(new DataFrame(stream.getId(), ByteBuffer.allocate(1), true), Callback.NOOP); - Assert.assertFalse(resetLatch.await(0, TimeUnit.SECONDS)); + Assert.assertFalse(resetLatch.await(1, TimeUnit.SECONDS)); } @Test From 37cda79f7bce39905127a7a67f77b12088d6910d Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 13 Jul 2016 15:28:10 +1000 Subject: [PATCH 2/2] Issue #720 --- .../src/main/java/org/eclipse/jetty/util/StringUtil.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java b/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java index 03d2a180fb7..e9692f0b95f 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java @@ -117,6 +117,9 @@ public class StringUtil */ public static String asciiToLowerCase(String s) { + if (s == null) + return null; + char[] c = null; int i=s.length();