From 3c3235b4cd045fa6ca566d6ff7b61617516351e9 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 4 Dec 2015 11:01:53 -0800 Subject: [PATCH 1/5] 8144742: Instrument intermittently failing test GCDuringIteration.java Reviewed-by: rriggs, martin --- jdk/test/TEST.groups | 2 ++ .../java/util/WeakHashMap/GCDuringIteration.java | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index fcb5f56d081..0600a4c8345 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -30,6 +30,7 @@ tier1 = \ -java/lang/ProcessHandle/TreeTest.java \ -java/util/zip/TestLocalTime.java \ :jdk_util \ + -java/util/WeakHashMap/GCDuringIteration.java \ -java/util/concurrent/Phaser/Basic.java \ sun/nio/cs/ISO8859x.java \ java/nio/Buffer \ @@ -40,6 +41,7 @@ tier2 = \ java/lang/ProcessHandle/TreeTest.java \ java/util/zip/TestLocalTime.java \ java/util/concurrent/Phaser/Basic.java \ + java/util/WeakHashMap/GCDuringIteration.java \ :jdk_io \ :jdk_nio \ -sun/nio/cs/ISO8859x.java \ diff --git a/jdk/test/java/util/WeakHashMap/GCDuringIteration.java b/jdk/test/java/util/WeakHashMap/GCDuringIteration.java index 1492e637980..663947f78b2 100644 --- a/jdk/test/java/util/WeakHashMap/GCDuringIteration.java +++ b/jdk/test/java/util/WeakHashMap/GCDuringIteration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,13 +24,17 @@ /* * @test * @bug 6499848 + * @library /lib/testlibrary/ + * @build jdk.testlibrary.RandomFactory + * @run main GCDuringIteration * @summary Check that iterators work properly in the presence of * concurrent finalization and removal of elements. - * @key randomness + * @key randomness intermittent */ import java.util.*; import java.util.concurrent.CountDownLatch; +import jdk.testlibrary.RandomFactory; public class GCDuringIteration { private static void waitForFinalizersToRun() { @@ -65,8 +69,9 @@ public class GCDuringIteration { equal(map.values().iterator().next(), v); } + static final Random rnd = RandomFactory.getRandom(); + void checkIterator(final Iterator> it, int first) { - final Random rnd = new Random(); for (int i = first; i >= 0; --i) { if (rnd.nextBoolean()) check(it.hasNext()); equal(it.next().getValue(), i); @@ -86,7 +91,7 @@ public class GCDuringIteration { final int n = 10; // Create array of strong refs final Foo[] foos = new Foo[2*n]; - final Map map = new WeakHashMap(foos.length); + final Map map = new WeakHashMap<>(foos.length); check(map.isEmpty()); equal(map.size(), 0); From 5675c04125f13e62f0c8c81128267d2edb7ae1cb Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Fri, 4 Dec 2015 12:28:09 -0800 Subject: [PATCH 2/5] 8143854: java/util/regex/RegExTest.java.RegExTest failed Reviewed-by: darcy --- jdk/test/java/util/regex/RegExTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/util/regex/RegExTest.java b/jdk/test/java/util/regex/RegExTest.java index b1c776138a7..b4abe1a4313 100644 --- a/jdk/test/java/util/regex/RegExTest.java +++ b/jdk/test/java/util/regex/RegExTest.java @@ -32,7 +32,7 @@ * 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133 * 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066 * 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590 - * 8027645 8035076 8039124 8035975 8074678 6854417 + * 8027645 8035076 8039124 8035975 8074678 6854417 8143854 * @library /lib/testlibrary * @build jdk.testlibrary.* * @run main RegExTest @@ -3568,7 +3568,7 @@ public class RegExTest { // Avoid patterns that start and end with the same substring // See JDK-6854417 - for (int x=1; x Date: Mon, 7 Dec 2015 03:35:24 +0000 Subject: [PATCH 3/5] 8141593: Test RetryHttps timed out intermittently Enable debug to expose more information for further evaluation Reviewed-by: weijun --- .../net/www/protocol/https/HttpsURLConnection/RetryHttps.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/RetryHttps.java b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/RetryHttps.java index a21c1b061e8..ae5da4078e0 100644 --- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/RetryHttps.java +++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/RetryHttps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,7 @@ public class RetryHttps { /* * Turn on SSL debugging? */ - static boolean debug = false; + static boolean debug = true; private SSLServerSocket sslServerSocket = null; From 2cde289af48520245d99682f68f16276115a3912 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Mon, 7 Dec 2015 15:48:56 +0800 Subject: [PATCH 4/5] 8138638: Security tests using jdk/test/sun/security/krb5/auto/KDC.java fail intermittently with OutOfMemoryError Reviewed-by: xuelei --- jdk/test/sun/security/krb5/auto/KDC.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jdk/test/sun/security/krb5/auto/KDC.java b/jdk/test/sun/security/krb5/auto/KDC.java index 066bb8d518b..1976c3d8a2b 100644 --- a/jdk/test/sun/security/krb5/auto/KDC.java +++ b/jdk/test/sun/security/krb5/auto/KDC.java @@ -1280,7 +1280,11 @@ public class KDC { System.out.println(">>>>> TCP connection established"); DataInputStream in = new DataInputStream(socket.getInputStream()); DataOutputStream out = new DataOutputStream(socket.getOutputStream()); - byte[] token = new byte[in.readInt()]; + int len = in.readInt(); + if (len > 65535) { + throw new Exception("Huge request not supported"); + } + byte[] token = new byte[len]; in.readFully(token); q.put(new Job(processMessage(token), socket, out)); } catch (Exception e) { From 66f1f09adb7b199c5767c99e84ed091deca23314 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Mon, 7 Dec 2015 12:35:37 +0100 Subject: [PATCH 5/5] 8144262: LogRecord.getMillis() method is a convenience API that should not have been deprecated LogRecord.getMillis() is no longer deprecated. LogRecord.setInstant() check that the instant millis can fit in a long millisecond-since-epoch. Reviewed-by: lancea, rriggs, smarks --- .../classes/java/util/logging/LogRecord.java | 20 +++++++++---- .../LogRecordWithNanosAPI.java | 29 ++++++++++++++++++- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java b/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java index 7cf7aee1eec..4a75c82bcee 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/LogRecord.java @@ -468,12 +468,11 @@ public class LogRecord implements java.io.Serializable { * @implSpec This is equivalent to calling * {@link #getInstant() getInstant().toEpochMilli()}. * - * @deprecated To get the full nanosecond resolution event time, + * @apiNote To get the full nanosecond resolution event time, * use {@link #getInstant()}. * * @see #getInstant() */ - @Deprecated public long getMillis() { return instant.toEpochMilli(); } @@ -487,8 +486,10 @@ public class LogRecord implements java.io.Serializable { * {@link #setInstant(java.time.Instant) * setInstant(Instant.ofEpochMilli(millis))}. * - * @deprecated To set event time with nanosecond resolution, - * use {@link #setInstant(java.time.Instant)}. + * @deprecated LogRecord maintains timestamps with nanosecond resolution, + * using {@link Instant} values. For this reason, + * {@link #setInstant(java.time.Instant) setInstant()} + * should be used in preference to {@code setMillis()}. * * @see #setInstant(java.time.Instant) */ @@ -510,14 +511,23 @@ public class LogRecord implements java.io.Serializable { /** * Sets the instant that the event occurred. + *

+ * If the given {@code instant} represents a point on the time-line too + * far in the future or past to fit in a {@code long} milliseconds and + * nanoseconds adjustment, then an {@code ArithmeticException} will be + * thrown. * * @param instant the instant that the event occurred. * * @throws NullPointerException if {@code instant} is null. + * @throws ArithmeticException if numeric overflow would occur while + * calling {@link Instant#toEpochMilli() instant.toEpochMilli()}. + * * @since 1.9 */ public void setInstant(Instant instant) { - this.instant = Objects.requireNonNull(instant); + instant.toEpochMilli(); + this.instant = instant; } /** diff --git a/jdk/test/java/util/logging/HigherResolutionTimeStamps/LogRecordWithNanosAPI.java b/jdk/test/java/util/logging/HigherResolutionTimeStamps/LogRecordWithNanosAPI.java index 0c6cfce652b..a858a8a7c9c 100644 --- a/jdk/test/java/util/logging/HigherResolutionTimeStamps/LogRecordWithNanosAPI.java +++ b/jdk/test/java/util/logging/HigherResolutionTimeStamps/LogRecordWithNanosAPI.java @@ -33,7 +33,7 @@ import java.util.logging.SimpleFormatter; /** * @test - * @bug 8072645 + * @bug 8072645 8144262 * @summary tests the new methods added to LogRecord. * @run main LogRecordWithNanosAPI * @author danielfuchs @@ -299,10 +299,37 @@ public class LogRecordWithNanosAPI { try { record.setInstant(null); + throw new RuntimeException("Expected NullPointerException not thrown"); } catch (NullPointerException x) { System.out.println("Got expected NPE when trying to call record.setInstant(null): " + x); } + // This instant is the biggest for which toEpochMilli will not throw... + final Instant max = Instant.ofEpochMilli(Long.MAX_VALUE).plusNanos(999_999L); + record.setInstant(max); + assertEquals(Long.MAX_VALUE / 1000L, + record.getInstant().getEpochSecond(), + "max instant seconds [record.getInstant().getEpochSecond()]"); + assertEquals(Long.MAX_VALUE, + record.getInstant().toEpochMilli(), + "max instant millis [record.getInstant().toEpochMilli()]"); + assertEquals(Long.MAX_VALUE, record.getMillis(), + "max instant millis [record.getMillis()]"); + assertEquals((Long.MAX_VALUE % 1000L)*1000_000L + 999_999L, + record.getInstant().getNano(), + "max instant nanos [record.getInstant().getNano()]"); + + // Too big by 1 ns. + final Instant tooBig = max.plusNanos(1L); + try { + record.setInstant(tooBig); + throw new RuntimeException("Expected ArithmeticException not thrown"); + } catch (ArithmeticException x) { + System.out.println("Got expected ArithmeticException when trying" + + " to call record.setInstant(Instant.ofEpochMilli(Long.MAX_VALUE)" + + ".plusNanos(999_999L).plusNanos(1L)): " + x); + } + } }