From ec67e938e252c1ecb61a2fb0d1a2f28db8ac9f65 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Sun, 13 Oct 2013 21:10:33 -0700 Subject: [PATCH 1/4] 8026119: Regression test DHEKeySizing.java failing intermittently Reviewed-by: weijun --- .../internal/ssl/DHKeyExchange/DHEKeySizing.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java index 3c61f76371f..ec61b303bc8 100644 --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java @@ -111,7 +111,15 @@ import java.util.Base64; public class DHEKeySizing { - private static boolean debug = true; + private final static boolean debug = true; + + // key length bias because of the stripping of leading zero bytes of + // negotiated DH keys. + // + // This is an effort to mimum intermittent failure when we cannot + // estimate what's the exact number of leading zero bytes of + // negotiated DH keys. + private final static int KEY_LEN_BIAS = 6; private SSLContext sslc; private SSLEngine ssle1; // client @@ -269,7 +277,8 @@ public class DHEKeySizing { twoToOne.flip(); log("Message length of ServerHello series: " + twoToOne.remaining()); - if (lenServerKeyEx != twoToOne.remaining()) { + if (twoToOne.remaining() < (lenServerKeyEx - KEY_LEN_BIAS) || + twoToOne.remaining() > lenServerKeyEx) { throw new Exception( "Expected to generate ServerHello series messages of " + lenServerKeyEx + " bytes, but not " + twoToOne.remaining()); @@ -289,7 +298,8 @@ public class DHEKeySizing { oneToTwo.flip(); log("Message length of ClientKeyExchange: " + oneToTwo.remaining()); - if (lenClientKeyEx != oneToTwo.remaining()) { + if (oneToTwo.remaining() < (lenClientKeyEx - KEY_LEN_BIAS) || + oneToTwo.remaining() > lenClientKeyEx) { throw new Exception( "Expected to generate ClientKeyExchange message of " + lenClientKeyEx + " bytes, but not " + oneToTwo.remaining()); From f573ee1917b325703f58e89a7d7a31502cb330ed Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Mon, 14 Oct 2013 10:42:36 +0200 Subject: [PATCH 2/4] 8024704: Improve API documentation of ClassLoader and ServiceLoader with respect to enumeration of resources Reviewed-by: alanb, psandoz, mchung --- jdk/src/share/classes/java/lang/ClassLoader.java | 11 +++++++++++ jdk/src/share/classes/java/util/ServiceLoader.java | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/jdk/src/share/classes/java/lang/ClassLoader.java b/jdk/src/share/classes/java/lang/ClassLoader.java index c3f2aa20458..3fd927482b3 100644 --- a/jdk/src/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/share/classes/java/lang/ClassLoader.java @@ -1061,6 +1061,10 @@ public abstract class ClassLoader { * built-in to the virtual machine is searched. That failing, this method * will invoke {@link #findResource(String)} to find the resource.

* + * @apiNote When overriding this method it is recommended that an + * implementation ensures that any delegation is consistent with the {@link + * #getResources(java.lang.String) getResources(String)} method. + * * @param name * The resource name * @@ -1094,6 +1098,13 @@ public abstract class ClassLoader { *

The search order is described in the documentation for {@link * #getResource(String)}.

* + * @apiNote When overriding this method it is recommended that an + * implementation ensures that any delegation is consistent with the {@link + * #getResource(java.lang.String) getResource(String)} method. This should + * ensure that the first element returned by the Enumeration's + * {@code nextElement} method is the same resource that the + * {@code getResource(String)} method would return. + * * @param name * The resource name * diff --git a/jdk/src/share/classes/java/util/ServiceLoader.java b/jdk/src/share/classes/java/util/ServiceLoader.java index aa5c3008818..f2473a950a2 100644 --- a/jdk/src/share/classes/java/util/ServiceLoader.java +++ b/jdk/src/share/classes/java/util/ServiceLoader.java @@ -453,6 +453,12 @@ public final class ServiceLoader * Invoking its {@link java.util.Iterator#remove() remove} method will * cause an {@link UnsupportedOperationException} to be thrown. * + * @implNote When adding providers to the cache, the {@link #iterator + * Iterator} processes resources in the order that the {@link + * java.lang.ClassLoader#getResources(java.lang.String) + * ClassLoader.getResources(String)} method finds the service configuration + * files. + * * @return An iterator that lazily loads providers for this loader's * service */ From 904f94625852e9029ec70f60760591e81060316b Mon Sep 17 00:00:00 2001 From: Tristan Yan Date: Mon, 14 Oct 2013 11:47:54 +0100 Subject: [PATCH 3/4] 8023555: test/java/net/Socks/SocksProxyVersion.java fails when machine name is localhost Reviewed-by: chegar, alanb --- jdk/test/java/net/Socks/SocksProxyVersion.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jdk/test/java/net/Socks/SocksProxyVersion.java b/jdk/test/java/net/Socks/SocksProxyVersion.java index bc46c423a09..27bd1872d40 100644 --- a/jdk/test/java/net/Socks/SocksProxyVersion.java +++ b/jdk/test/java/net/Socks/SocksProxyVersion.java @@ -41,6 +41,10 @@ public class SocksProxyVersion implements Runnable { volatile boolean failed; public static void main(String[] args) throws Exception { + if (InetAddress.getLocalHost().isLoopbackAddress()) { + System.out.println("Test cannot run. getLocalHost returns a loopback address"); + return; + } new SocksProxyVersion(); } From ba1c14b52747274215341a7a529f2c294824cb0f Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Mon, 14 Oct 2013 14:28:50 +0200 Subject: [PATCH 4/4] 7196801: NPG: Fix java/lang/management/MemoryMXBean/LowMemoryTest2 Co-authored-by: Coleen Phillimore Reviewed-by: coleenp, sla --- .../MemoryMXBean/LowMemoryTest2.java | 25 ++++++++++++++----- .../management/MemoryMXBean/LowMemoryTest2.sh | 15 ++++++----- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.java b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.java index 059e45d409d..d0f9e9aa4ff 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.java +++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.java @@ -26,7 +26,7 @@ * * The test set a listener to be notified when any of the non-heap pools * exceed 80%. It then starts a thread that continuously loads classes. - * In the HotSpot implementation this causes perm space to be consumed. + * In the HotSpot implementation this causes metaspace to be consumed. * Test completes when we the notification is received or an OutOfMemory * is generated. */ @@ -100,7 +100,14 @@ public class LowMemoryTest2 { // TestNNNNNN - String name = "Test" + Integer.toString(count++); + int load_count = count++; + if (load_count > 999999) { + // The test will create a corrupt class file if the count + // exceeds 999999. Fix the test if this exception is thrown. + throw new RuntimeException("Load count exceeded"); + } + + String name = "Test" + Integer.toString(load_count); byte value[]; try { @@ -133,8 +140,9 @@ public class LowMemoryTest2 { * Note: Once the usage threshold has been exceeded the low memory * detector thread will attempt to deliver its notification - this can * potentially create a race condition with this thread contining to - * fill up perm space. To avoid the low memory detector getting an OutOfMemory - * we throttle this thread once the threshold has been exceeded. + * fill up metaspace. To avoid the low memory detector getting an + * OutOfMemory we throttle this thread once the threshold has been + * exceeded. */ public void run() { List pools = ManagementFactory.getMemoryPoolMXBeans(); @@ -180,7 +188,7 @@ public class LowMemoryTest2 { // Set threshold of 80% of all NON_HEAP memory pools // In the Hotspot implementation this means we should get a notification - // if the CodeCache or perm generation fills up. + // if the CodeCache or metaspace fills up. while (iter.hasNext()) { MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next(); @@ -188,7 +196,12 @@ public class LowMemoryTest2 { // set threshold MemoryUsage mu = p.getUsage(); - long threshold = (mu.getMax() * 80) / 100; + long max = mu.getMax(); + if (max < 0) { + throw new RuntimeException("There is no maximum set for " + + p.getName() + " memory pool so the test is invalid"); + } + long threshold = (max * 80) / 100; p.setUsageThreshold(threshold); diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh index 44b757214fd..3d97270fb35 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh +++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh @@ -51,14 +51,17 @@ go() { # Run test with each GC configuration # -# Notes: To ensure that perm gen fills up we disable class unloading. -# Also we set the max perm space to 8MB - otherwise the test takes too +# Notes: To ensure that metaspace fills up we disable class unloading. +# Also we set the max metaspace to 8MB - otherwise the test takes too # long to run. -go -noclassgc -XX:PermSize=8m -XX:MaxPermSize=8m -XX:+UseSerialGC LowMemoryTest2 -go -noclassgc -XX:PermSize=8m -XX:MaxPermSize=8m -XX:+UseParallelGC LowMemoryTest2 -go -noclassgc -XX:PermSize=8m -XX:MaxPermSize=8m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC \ - LowMemoryTest2 +go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseSerialGC LowMemoryTest2 +go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseParallelGC LowMemoryTest2 +go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC LowMemoryTest2 + +# Test class metaspace - might hit MaxMetaspaceSize instead if +# UseCompressedClassPointers is off or if 32 bit. +go -noclassgc -XX:MaxMetaspaceSize=16m -XX:CompressedClassSpaceSize=4m LowMemoryTest2 echo '' if [ $failures -gt 0 ];