changeset 17604:6c9eebfedd13

Merge
author prr
date Tue, 30 Aug 2016 08:45:21 -0700
parents 145d979bb1fb 556549260289
children ce0716535c7e 9c4ef5048871
files
diffstat 8 files changed, 121 insertions(+), 89 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java	Tue Aug 30 11:07:58 2016 +0530
+++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java	Tue Aug 30 08:45:21 2016 -0700
@@ -47,8 +47,8 @@
 
     private final JrtPath dir;
     private final DirectoryStream.Filter<? super Path> filter;
-    private volatile boolean isClosed;
-    private volatile Iterator<Path> itr;
+    private boolean isClosed;
+    private Iterator<Path> itr;
 
     JrtDirectoryStream(JrtPath dir,
             DirectoryStream.Filter<? super java.nio.file.Path> filter)
@@ -73,24 +73,22 @@
             throw new IllegalStateException(e);
         }
         return new Iterator<Path>() {
-            private Path next;
             @Override
-            public synchronized boolean hasNext() {
-                if (isClosed)
-                    return false;
-                return itr.hasNext();
+            public boolean hasNext() {
+                synchronized (JrtDirectoryStream.this) {
+                    if (isClosed)
+                        return false;
+                    return itr.hasNext();
+                }
             }
 
             @Override
-            public synchronized Path next() {
-                if (isClosed)
-                    throw new NoSuchElementException();
-                return itr.next();
-            }
-
-            @Override
-            public void remove() {
-                throw new UnsupportedOperationException();
+            public Path next() {
+                synchronized (JrtDirectoryStream.this) {
+                    if (isClosed)
+                        throw new NoSuchElementException();
+                    return itr.next();
+                }
             }
         };
     }
--- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java	Tue Aug 30 11:07:58 2016 +0530
+++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java	Tue Aug 30 08:45:21 2016 -0700
@@ -119,9 +119,7 @@
 
     @Override
     public Iterable<Path> getRootDirectories() {
-        ArrayList<Path> dirs = new ArrayList<>();
-        dirs.add(getRootPath());
-        return dirs;
+        return Collections.singleton(getRootPath());
     }
 
     @Override
@@ -159,9 +157,7 @@
 
     @Override
     public final Iterable<FileStore> getFileStores() {
-        ArrayList<FileStore> list = new ArrayList<>(1);
-        list.add(getFileStore(getRootPath()));
-        return list;
+        return Collections.singleton(getFileStore(getRootPath()));
     }
 
     private static final Set<String> supportedFileAttributeViews
--- a/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java	Tue Aug 30 11:07:58 2016 +0530
+++ b/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java	Tue Aug 30 08:45:21 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -75,10 +75,10 @@
             }
         }
         try {
-            card =  new CardImpl(this, protocol);
+            card = new CardImpl(this, protocol);
             return card;
         } catch (PCSCException e) {
-            if (e.code == SCARD_W_REMOVED_CARD) {
+            if (e.code == SCARD_W_REMOVED_CARD || e.code == SCARD_E_NO_SMARTCARD) {
                 throw new CardNotPresentException("No card present", e);
             } else {
                 throw new CardException("connect() failed", e);
--- a/test/java/lang/ProcessBuilder/Zombies.java	Tue Aug 30 11:07:58 2016 +0530
+++ b/test/java/lang/ProcessBuilder/Zombies.java	Tue Aug 30 08:45:21 2016 -0700
@@ -25,7 +25,6 @@
  * @test
  * @run main/othervm Zombies
  * @bug 6474073 6180151
- * @key intermittent
  * @summary Make sure zombies don't get created on Unix
  * @author Martin Buchholz
  */
--- a/test/java/net/URLPermission/nstest/lookup.sh	Tue Aug 30 11:07:58 2016 +0530
+++ b/test/java/net/URLPermission/nstest/lookup.sh	Tue Aug 30 08:45:21 2016 -0700
@@ -27,6 +27,7 @@
 # @build jdk.testlibrary.*
 # @compile -XDignore.symbol.file=true LookupTest.java
 # @run shell/timeout=50 lookup.sh
+# @key intermittent
 #
 
 OS=`uname -s`
--- a/test/sun/security/ssl/SSLSocketImpl/CloseSocket.java	Tue Aug 30 11:07:58 2016 +0530
+++ b/test/sun/security/ssl/SSLSocketImpl/CloseSocket.java	Tue Aug 30 08:45:21 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, 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
@@ -26,67 +26,96 @@
  * @bug 4674913
  * @summary Verify that EOFException are correctly handled during the handshake
  * @author Andreas Sterbenz
+ * @run main/othervm CloseSocket
  */
 
-import java.io.*;
-import java.net.*;
-
-import javax.net.ssl.*;
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.ArrayList;
 
 public class CloseSocket {
 
+    private static ArrayList<TestCase> testCases = new ArrayList<>();
+
+    static {
+        testCases.add(socket -> socket.startHandshake());
+        testCases.add(socket -> {
+            InputStream in = socket.getInputStream();
+            in.read();
+        });
+        testCases.add(socket -> {
+            OutputStream out = socket.getOutputStream();
+            out.write(43);
+        });
+    }
+
     public static void main(String[] args) throws Exception {
-        final ServerSocket serverSocket = new ServerSocket(0);
-        int serverPort = serverSocket.getLocalPort();
-        new Thread() {
-            public void run() {
-                try {
-                    Socket s = serverSocket.accept();
-                    System.out.println("Server accepted connection");
-                    // wait a bit before closing the socket to give
-                    // the client time to send its hello message
-                    Thread.currentThread().sleep(100);
-                    s.close();
-                    System.out.println("Server closed socket, done.");
-                } catch (Exception e) {
-                    System.out.println("Server exception:");
-                    e.printStackTrace();
+        try (Server server = new Server()) {
+            new Thread(server).start();
+
+            SocketFactory factory = SSLSocketFactory.getDefault();
+            try (SSLSocket socket = (SSLSocket) factory.createSocket("localhost",
+                    server.getPort())) {
+                socket.setSoTimeout(2000);
+                System.out.println("Client established TCP connection");
+                boolean failed = false;
+                for (TestCase testCase : testCases) {
+                    try {
+                        testCase.test(socket);
+                        System.out.println("ERROR: no exception");
+                        failed = true;
+                    } catch (IOException e) {
+                        System.out.println("Failed as expected: " + e);
+                    }
+                }
+                if (failed) {
+                    throw new Exception("One or more tests failed");
                 }
             }
-        }.start();
-        SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
-        SSLSocket socket = (SSLSocket)factory.createSocket("localhost", serverPort);
-        System.out.println("Client established TCP connection");
-        boolean failed = false;
-        try {
-            System.out.println("Starting handshake...");
-            socket.startHandshake();
-            System.out.println("ERROR: no exception");
-            failed = true;
-        } catch (IOException e) {
-            System.out.println("Failed as expected: " + e);
-        }
-        try {
-            System.out.println("Trying read...");
-            InputStream in = socket.getInputStream();
-            int b = in.read();
-            System.out.println("ERROR: no exception, read: " + b);
-            failed = true;
-        } catch (IOException e) {
-            System.out.println("Failed as expected: " + e);
-        }
-        try {
-            System.out.println("Trying read...");
-            OutputStream out = socket.getOutputStream();
-            out.write(43);
-            System.out.println("ERROR: no exception");
-            failed = true;
-        } catch (IOException e) {
-            System.out.println("Failed as expected: " + e);
-        }
-        if (failed) {
-            throw new Exception("One or more tests failed");
         }
     }
 
+    static class Server implements AutoCloseable, Runnable {
+
+        final ServerSocket serverSocket;
+
+        Server() throws IOException {
+            serverSocket = new ServerSocket(0);
+        }
+
+        public int getPort() {
+            return serverSocket.getLocalPort();
+        }
+
+        @Override
+        public void run() {
+            try (Socket s = serverSocket.accept()) {
+                System.out.println("Server accepted connection");
+                // wait a bit before closing the socket to give
+                // the client time to send its hello message
+                Thread.currentThread().sleep(100);
+                s.close();
+                System.out.println("Server closed socket, done.");
+            } catch (Exception e) {
+                throw new RuntimeException("Problem in test execution", e);
+            }
+        }
+
+        @Override
+        public void close() throws Exception {
+            if (!serverSocket.isClosed()) {
+                serverSocket.close();
+            }
+        }
+    }
+
+    interface TestCase {
+        void test(SSLSocket socket) throws IOException;
+    }
 }
--- a/test/sun/util/calendar/zi/TestZoneInfo310.java	Tue Aug 30 11:07:58 2016 +0530
+++ b/test/sun/util/calendar/zi/TestZoneInfo310.java	Tue Aug 30 08:45:21 2016 -0700
@@ -22,11 +22,15 @@
  */
 
 /*
- *@test
- *@bug 8007572 8008161
- *@summary Test whether the TimeZone generated from JSR310 tzdb is the same
- *as the one from the tz data from javazic
+ * @test
+ * @bug 8007572 8008161 8157792
+ * @summary Test whether the TimeZone generated from JSR310 tzdb is the same
+ * as the one from the tz data from javazic
  * @modules java.base/sun.util.calendar
+ * @build BackEnd Checksum DayOfWeek Gen GenDoc Main Mappings Month
+ *        Rule RuleDay RuleRec Simple TestZoneInfo310 Time Timezone
+ *        TzIDOldMapping Zone ZoneInfoFile ZoneInfoOld ZoneRec Zoneinfo
+ * @run main TestZoneInfo310
  */
 
 import java.io.File;
@@ -164,10 +168,6 @@
         }
 
         for (String zid : zids_new) {
-            if (zid.equals("Asia/Oral") || zid.equals("Asia/Qyzylorda")) {
-                // JDK-8157792 tracking this issue
-                continue;
-            }
             ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid));
             ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid);
             if (! zi.equalsTo(ziOLD)) {
--- a/test/sun/util/calendar/zi/Zoneinfo.java	Tue Aug 30 11:07:58 2016 +0530
+++ b/test/sun/util/calendar/zi/Zoneinfo.java	Tue Aug 30 08:45:21 2016 -0700
@@ -373,6 +373,7 @@
         tz.getOffsetIndex(zrec.getGmtOffset());
 
         int lastGmtOffsetValue = -1;
+        ZoneRec prevzrec = null;
         int currentSave = 0;
         boolean usedZone;
         for (int zindex = 0; zindex < zone.size(); zindex++) {
@@ -441,6 +442,15 @@
                                                                      currentSave);
                             if (zrec.hasUntil()) {
                                 if (transition >= zrec.getUntilTime(currentSave)) {
+                                    // If the GMT offset changed from the previous one,
+                                    // record fromTime as a transition.
+                                    if (!fromTimeUsed && prevzrec != null
+                                        && gmtOffset != prevzrec.getGmtOffset()) {
+                                        tz.addTransition(fromTime,
+                                                         tz.getOffsetIndex(gmtOffset+currentSave),
+                                                         tz.getDstOffsetIndex(currentSave));
+                                        fromTimeUsed = true; // for consistency
+                                    }
                                     break year_loop;
                                 }
                             }
@@ -452,8 +462,6 @@
                                     if (fromTime != minTime) {
                                         int prevsave;
 
-                                        ZoneRec prevzrec = zone.get(zindex - 1);
-
                                         // See if until time in the previous
                                         // ZoneRec is the same thing as the
                                         // local time in the next rule.
@@ -555,6 +563,7 @@
                 fromYear = zrec.getUntilYear();
                 year = zrec.getUntilYear();
             }
+            prevzrec = zrec;
         }
 
         if (tz.getDSTType() == Timezone.UNDEF_DST) {