changeset 13272:64dcdca11308

Merge
author amurillo
date Mon, 07 Dec 2015 10:05:08 -0800
parents 2e1c3bb37d11 dc3322ef23ff
children 24e271303228
files
diffstat 7 files changed, 63 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.logging/share/classes/java/util/logging/LogRecord.java	Thu Dec 03 22:30:21 2015 -0800
+++ b/src/java.logging/share/classes/java/util/logging/LogRecord.java	Mon Dec 07 10:05:08 2015 -0800
@@ -468,12 +468,11 @@
      * @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 @@
      *      {@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 @@
 
     /**
      * Sets the instant that the event occurred.
+     * <p>
+     * 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;
     }
 
     /**
--- a/test/TEST.groups	Thu Dec 03 22:30:21 2015 -0800
+++ b/test/TEST.groups	Mon Dec 07 10:05:08 2015 -0800
@@ -30,6 +30,7 @@
     -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 @@
     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 \
--- a/test/java/util/WeakHashMap/GCDuringIteration.java	Thu Dec 03 22:30:21 2015 -0800
+++ b/test/java/util/WeakHashMap/GCDuringIteration.java	Mon Dec 07 10:05:08 2015 -0800
@@ -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 @@
         equal(map.values().iterator().next(), v);
     }
 
+    static final Random rnd = RandomFactory.getRandom();
+
     void checkIterator(final Iterator<Map.Entry<Foo, Integer>> 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 @@
         final int n = 10;
         // Create array of strong refs
         final Foo[] foos = new Foo[2*n];
-        final Map<Foo,Integer> map = new WeakHashMap<Foo,Integer>(foos.length);
+        final Map<Foo,Integer> map = new WeakHashMap<>(foos.length);
         check(map.isEmpty());
         equal(map.size(), 0);
 
--- a/test/java/util/logging/HigherResolutionTimeStamps/LogRecordWithNanosAPI.java	Thu Dec 03 22:30:21 2015 -0800
+++ b/test/java/util/logging/HigherResolutionTimeStamps/LogRecordWithNanosAPI.java	Mon Dec 07 10:05:08 2015 -0800
@@ -33,7 +33,7 @@
 
 /**
  * @test
- * @bug 8072645
+ * @bug 8072645 8144262
  * @summary tests the new methods added to LogRecord.
  * @run main LogRecordWithNanosAPI
  * @author danielfuchs
@@ -299,10 +299,37 @@
 
         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);
+        }
+
     }
 
 }
--- a/test/java/util/regex/RegExTest.java	Thu Dec 03 22:30:21 2015 -0800
+++ b/test/java/util/regex/RegExTest.java	Mon Dec 07 10:05:08 2015 -0800
@@ -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 @@
 
                 // Avoid patterns that start and end with the same substring
                 // See JDK-6854417
-                for (int x=1; x <patternLength; x++) {
+                for (int x=1; x < pattern.length(); x++) {
                     if (pattern.startsWith(pattern.substring(x)))
                         continue retry;
                 }
--- a/test/sun/net/www/protocol/https/HttpsURLConnection/RetryHttps.java	Thu Dec 03 22:30:21 2015 -0800
+++ b/test/sun/net/www/protocol/https/HttpsURLConnection/RetryHttps.java	Mon Dec 07 10:05:08 2015 -0800
@@ -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 @@
     /*
      * Turn on SSL debugging?
      */
-    static boolean debug = false;
+    static boolean debug = true;
 
     private SSLServerSocket sslServerSocket = null;
 
--- a/test/sun/security/krb5/auto/KDC.java	Thu Dec 03 22:30:21 2015 -0800
+++ b/test/sun/security/krb5/auto/KDC.java	Mon Dec 07 10:05:08 2015 -0800
@@ -1280,7 +1280,11 @@
                         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) {