From 8a155cc86f02052965163ba5c46eabf13a7bd937 Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Tue, 13 Dec 2016 17:40:53 -0800 Subject: [PATCH 1/2] 8171072: java/rmi/transport/handshake*/Handshake*.java, exception is not thrown when reach failure test case Reviewed-by: rriggs --- .../transport/handshakeFailure/HandshakeFailure.java | 12 +++++------- .../transport/handshakeTimeout/HandshakeTimeout.java | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/jdk/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java b/jdk/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java index fc7341f7be3..d99e967cc7f 100644 --- a/jdk/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java +++ b/jdk/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -30,12 +30,10 @@ * java.rmi.ConnectException or ConnectIOException, not a MarshalException. * @author Peter Jones * - * @library ../../testlibrary * @modules java.rmi/sun.rmi.registry * java.rmi/sun.rmi.server * java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport.tcp - * @build TestLibrary * @run main/othervm HandshakeFailure */ @@ -49,7 +47,6 @@ import java.rmi.registry.Registry; public class HandshakeFailure { - private static final int PORT = TestLibrary.getUnusedRandomPort(); private static final int TIMEOUT = 10000; public static void main(String[] args) throws Exception { @@ -57,12 +54,13 @@ public class HandshakeFailure { /* * Listen on port... */ - ServerSocket serverSocket = new ServerSocket(PORT); + ServerSocket serverSocket = new ServerSocket(0); + int port = serverSocket.getLocalPort(); /* * (Attempt RMI call to port in separate thread.) */ - Registry registry = LocateRegistry.getRegistry(PORT); + Registry registry = LocateRegistry.getRegistry(port); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); @@ -93,7 +91,7 @@ public class HandshakeFailure { System.err.println(); if (connector.exception instanceof MarshalException) { - System.err.println( + throw new RuntimeException( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || diff --git a/jdk/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java b/jdk/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java index 7a20f20234c..d763b55c455 100644 --- a/jdk/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java +++ b/jdk/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -33,12 +33,10 @@ * this point (because no data for the invocation has yet been written). * @author Peter Jones * - * @library ../../testlibrary * @modules java.rmi/sun.rmi.registry * java.rmi/sun.rmi.server * java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport.tcp - * @build TestLibrary * @run main/othervm HandshakeTimeout */ @@ -51,7 +49,6 @@ import java.rmi.registry.Registry; public class HandshakeTimeout { - private static final int PORT = TestLibrary.getUnusedRandomPort(); private static final int TIMEOUT = 10000; public static void main(String[] args) throws Exception { @@ -62,12 +59,13 @@ public class HandshakeTimeout { /* * Listen on port, but never process connections made to it. */ - ServerSocket serverSocket = new ServerSocket(PORT); + ServerSocket serverSocket = new ServerSocket(0); + int port = serverSocket.getLocalPort(); /* * Attempt RMI call to port in separate thread. */ - Registry registry = LocateRegistry.getRegistry(PORT); + Registry registry = LocateRegistry.getRegistry(port); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); @@ -91,7 +89,7 @@ public class HandshakeTimeout { System.err.println(); if (connector.exception instanceof MarshalException) { - System.err.println( + throw new RuntimeException( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || From 292fe71e60f2c50bf9f1fd9177188b1fe3dd93c0 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Tue, 13 Dec 2016 17:45:37 -0800 Subject: [PATCH 2/2] 8170943: Collectors.partitioningBy should specify that false and true entries are always present Reviewed-by: psandoz --- .../classes/java/util/stream/Collectors.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java index 8a53a27589e..17c743a9064 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java +++ b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java @@ -1268,10 +1268,16 @@ public final class Collectors { * to a {@code Predicate}, and organizes them into a * {@code Map>}. * + * The returned {@code Map} always contains mappings for both + * {@code false} and {@code true} keys. * There are no guarantees on the type, mutability, * serializability, or thread-safety of the {@code Map} or {@code List} * returned. * + * @apiNote + * If a partition has no elements, its value in the result Map will be + * an empty List. + * * @param the type of the input elements * @param predicate a predicate used for classifying input elements * @return a {@code Collector} implementing the partitioning operation @@ -1290,9 +1296,17 @@ public final class Collectors { * {@code Map} whose values are the result of the downstream * reduction. * - *

There are no guarantees on the type, mutability, + *

+ * The returned {@code Map} always contains mappings for both + * {@code false} and {@code true} keys. + * There are no guarantees on the type, mutability, * serializability, or thread-safety of the {@code Map} returned. * + * @apiNote + * If a partition has no elements, its value in the result Map will be + * obtained by calling the downstream collector's supplier function and then + * applying the finisher function. + * * @param the type of the input elements * @param the intermediate accumulation type of the downstream collector * @param the result type of the downstream reduction