This commit is contained in:
Jesper Wilhelmsson 2016-12-14 03:09:12 +01:00
commit c6fe9d621b
3 changed files with 25 additions and 15 deletions

View File

@ -1268,10 +1268,16 @@ public final class Collectors {
* to a {@code Predicate}, and organizes them into a * to a {@code Predicate}, and organizes them into a
* {@code Map<Boolean, List<T>>}. * {@code Map<Boolean, List<T>>}.
* *
* The returned {@code Map} always contains mappings for both
* {@code false} and {@code true} keys.
* There are no guarantees on the type, mutability, * There are no guarantees on the type, mutability,
* serializability, or thread-safety of the {@code Map} or {@code List} * serializability, or thread-safety of the {@code Map} or {@code List}
* returned. * returned.
* *
* @apiNote
* If a partition has no elements, its value in the result Map will be
* an empty List.
*
* @param <T> the type of the input elements * @param <T> the type of the input elements
* @param predicate a predicate used for classifying input elements * @param predicate a predicate used for classifying input elements
* @return a {@code Collector} implementing the partitioning operation * @return a {@code Collector} implementing the partitioning operation
@ -1290,9 +1296,17 @@ public final class Collectors {
* {@code Map<Boolean, D>} whose values are the result of the downstream * {@code Map<Boolean, D>} whose values are the result of the downstream
* reduction. * reduction.
* *
* <p>There are no guarantees on the type, mutability, * <p>
* 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. * 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 <T> the type of the input elements * @param <T> the type of the input elements
* @param <A> the intermediate accumulation type of the downstream collector * @param <A> the intermediate accumulation type of the downstream collector
* @param <D> the result type of the downstream reduction * @param <D> the result type of the downstream reduction

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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. * java.rmi.ConnectException or ConnectIOException, not a MarshalException.
* @author Peter Jones * @author Peter Jones
* *
* @library ../../testlibrary
* @modules java.rmi/sun.rmi.registry * @modules java.rmi/sun.rmi.registry
* java.rmi/sun.rmi.server * java.rmi/sun.rmi.server
* java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport
* java.rmi/sun.rmi.transport.tcp * java.rmi/sun.rmi.transport.tcp
* @build TestLibrary
* @run main/othervm HandshakeFailure * @run main/othervm HandshakeFailure
*/ */
@ -49,7 +47,6 @@ import java.rmi.registry.Registry;
public class HandshakeFailure { public class HandshakeFailure {
private static final int PORT = TestLibrary.getUnusedRandomPort();
private static final int TIMEOUT = 10000; private static final int TIMEOUT = 10000;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
@ -57,12 +54,13 @@ public class HandshakeFailure {
/* /*
* Listen on port... * 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.) * (Attempt RMI call to port in separate thread.)
*/ */
Registry registry = LocateRegistry.getRegistry(PORT); Registry registry = LocateRegistry.getRegistry(port);
Connector connector = new Connector(registry); Connector connector = new Connector(registry);
Thread t = new Thread(connector); Thread t = new Thread(connector);
t.setDaemon(true); t.setDaemon(true);
@ -93,7 +91,7 @@ public class HandshakeFailure {
System.err.println(); System.err.println();
if (connector.exception instanceof MarshalException) { if (connector.exception instanceof MarshalException) {
System.err.println( throw new RuntimeException(
"TEST FAILED: MarshalException thrown, expecting " + "TEST FAILED: MarshalException thrown, expecting " +
"java.rmi.ConnectException or ConnectIOException"); "java.rmi.ConnectException or ConnectIOException");
} else if (connector.exception instanceof ConnectException || } else if (connector.exception instanceof ConnectException ||

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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). * this point (because no data for the invocation has yet been written).
* @author Peter Jones * @author Peter Jones
* *
* @library ../../testlibrary
* @modules java.rmi/sun.rmi.registry * @modules java.rmi/sun.rmi.registry
* java.rmi/sun.rmi.server * java.rmi/sun.rmi.server
* java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport
* java.rmi/sun.rmi.transport.tcp * java.rmi/sun.rmi.transport.tcp
* @build TestLibrary
* @run main/othervm HandshakeTimeout * @run main/othervm HandshakeTimeout
*/ */
@ -51,7 +49,6 @@ import java.rmi.registry.Registry;
public class HandshakeTimeout { public class HandshakeTimeout {
private static final int PORT = TestLibrary.getUnusedRandomPort();
private static final int TIMEOUT = 10000; private static final int TIMEOUT = 10000;
public static void main(String[] args) throws Exception { 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. * 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. * Attempt RMI call to port in separate thread.
*/ */
Registry registry = LocateRegistry.getRegistry(PORT); Registry registry = LocateRegistry.getRegistry(port);
Connector connector = new Connector(registry); Connector connector = new Connector(registry);
Thread t = new Thread(connector); Thread t = new Thread(connector);
t.setDaemon(true); t.setDaemon(true);
@ -91,7 +89,7 @@ public class HandshakeTimeout {
System.err.println(); System.err.println();
if (connector.exception instanceof MarshalException) { if (connector.exception instanceof MarshalException) {
System.err.println( throw new RuntimeException(
"TEST FAILED: MarshalException thrown, expecting " + "TEST FAILED: MarshalException thrown, expecting " +
"java.rmi.ConnectException or ConnectIOException"); "java.rmi.ConnectException or ConnectIOException");
} else if (connector.exception instanceof ConnectException || } else if (connector.exception instanceof ConnectException ||