8185099: Miscellaneous changes imported from jsr166 CVS 2017-08

Reviewed-by: martin, psandoz
This commit is contained in:
Doug Lea 2017-08-09 17:40:38 -07:00
parent 9f28d43df5
commit 2f31db126d
37 changed files with 89 additions and 92 deletions

View File

@ -85,9 +85,9 @@ package java.util.concurrent;
* this.executor = executor;
* }
* public synchronized void request(long n) {
* if (n != 0 && !completed) {
* if (!completed) {
* completed = true;
* if (n < 0) {
* if (n <= 0) {
* IllegalArgumentException ex = new IllegalArgumentException();
* executor.execute(() -> subscriber.onError(ex));
* } else {

View File

@ -576,7 +576,7 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
private static final RuntimePermission shutdownPerm =
new RuntimePermission("modifyThread");
/* The context to be used when executing the finalizer, or null. */
/** The context to be used when executing the finalizer, or null. */
private final AccessControlContext acc;
/**
@ -1314,9 +1314,9 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
throw new IllegalArgumentException();
if (workQueue == null || threadFactory == null || handler == null)
throw new NullPointerException();
this.acc = System.getSecurityManager() == null ?
null :
AccessController.getContext();
this.acc = (System.getSecurityManager() == null)
? null
: AccessController.getContext();
this.corePoolSize = corePoolSize;
this.maximumPoolSize = maximumPoolSize;
this.workQueue = workQueue;

View File

@ -903,7 +903,7 @@ public class ArrayBlockingQueueTest extends JSR166TestCase {
}
/**
* A deserialized serialized queue has same elements in same order
* A deserialized/reserialized queue has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);

View File

@ -939,7 +939,7 @@ public class ArrayDequeTest extends JSR166TestCase {
}
/**
* A deserialized serialized deque has same elements in same order
* A deserialized/reserialized deque has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedDeque(SIZE);

View File

@ -33,6 +33,7 @@
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import junit.framework.Test;
@ -61,4 +62,27 @@ public class ArrayListTest extends JSR166TestCase {
CollectionTest.testSuite(new SubListImplementation()));
}
/**
* A cloned list equals original
*/
public void testClone() throws Exception {
ArrayList<Integer> x = new ArrayList<>();
x.add(1);
x.add(2);
x.add(3);
ArrayList<Integer> y = (ArrayList<Integer>) x.clone();
assertNotSame(y, x);
assertEquals(x, y);
assertEquals(y, x);
assertEquals(x.size(), y.size());
assertEquals(x.toString(), y.toString());
assertTrue(Arrays.equals(x.toArray(), y.toArray()));
while (!x.isEmpty()) {
assertFalse(y.isEmpty());
assertEquals(x.remove(0), y.remove(0));
}
assertTrue(y.isEmpty());
}
}

View File

@ -147,7 +147,7 @@ public class AtomicBooleanTest extends JSR166TestCase {
}
/**
* a deserialized serialized atomic holds same value
* a deserialized/reserialized atomic holds same value
*/
public void testSerialization() throws Exception {
AtomicBoolean x = new AtomicBoolean();

View File

@ -342,7 +342,7 @@ public class AtomicIntegerArrayTest extends JSR166TestCase {
}
/**
* a deserialized serialized array holds same values
* a deserialized/reserialized array holds same values in same order
*/
public void testSerialization() throws Exception {
AtomicIntegerArray x = new AtomicIntegerArray(SIZE);

View File

@ -218,7 +218,7 @@ public class AtomicIntegerTest extends JSR166TestCase {
}
/**
* a deserialized serialized atomic holds same value
* a deserialized/reserialized atomic holds same value
*/
public void testSerialization() throws Exception {
AtomicInteger x = new AtomicInteger();

View File

@ -341,7 +341,7 @@ public class AtomicLongArrayTest extends JSR166TestCase {
}
/**
* a deserialized serialized array holds same values
* a deserialized/reserialized array holds same values in same order
*/
public void testSerialization() throws Exception {
AtomicLongArray x = new AtomicLongArray(SIZE);

View File

@ -220,7 +220,7 @@ public class AtomicLongTest extends JSR166TestCase {
}
/**
* a deserialized serialized atomic holds same value
* a deserialized/reserialized atomic holds same value
*/
public void testSerialization() throws Exception {
AtomicLong x = new AtomicLong();

View File

@ -220,7 +220,7 @@ public class AtomicReferenceArrayTest extends JSR166TestCase {
}
/**
* a deserialized serialized array holds same values
* a deserialized/reserialized array holds same values in same order
*/
public void testSerialization() throws Exception {
AtomicReferenceArray x = new AtomicReferenceArray(SIZE);

View File

@ -143,7 +143,7 @@ public class AtomicReferenceTest extends JSR166TestCase {
}
/**
* a deserialized serialized atomic holds same value
* a deserialized/reserialized atomic holds same value
*/
public void testSerialization() throws Exception {
AtomicReference x = new AtomicReference();

View File

@ -570,7 +570,7 @@ public class ConcurrentHashMap8Test extends JSR166TestCase {
}
/**
* A deserialized serialized set is equal
* A deserialized/reserialized set equals original
*/
public void testSerialization() throws Exception {
int size = 20;

View File

@ -811,7 +811,7 @@ public class ConcurrentHashMapTest extends JSR166TestCase {
}
/**
* A deserialized map equals original
* A deserialized/reserialized map equals original
*/
public void testSerialization() throws Exception {
Map x = map5();

View File

@ -889,7 +889,7 @@ public class ConcurrentLinkedDequeTest extends JSR166TestCase {
}
/**
* A deserialized serialized deque has same elements in same order
* A deserialized/reserialized deque has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedDeque(SIZE);

View File

@ -538,7 +538,7 @@ public class ConcurrentLinkedQueueTest extends JSR166TestCase {
}
/**
* A deserialized serialized queue has same elements in same order
* A deserialized/reserialized queue has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);

View File

@ -828,7 +828,24 @@ public class ConcurrentSkipListMapTest extends JSR166TestCase {
}
/**
* A deserialized map equals original
* A cloned map equals original
*/
public void testClone() {
ConcurrentSkipListMap x = map5();
ConcurrentSkipListMap y = x.clone();
assertNotSame(x, y);
assertEquals(x.size(), y.size());
assertEquals(x.toString(), y.toString());
assertEquals(x, y);
assertEquals(y, x);
y.clear();
assertTrue(y.isEmpty());
assertFalse(x.equals(y));
}
/**
* A deserialized/reserialized map equals original
*/
public void testSerialization() throws Exception {
NavigableMap x = map5();
@ -839,6 +856,9 @@ public class ConcurrentSkipListMapTest extends JSR166TestCase {
assertEquals(x.toString(), y.toString());
assertEquals(x, y);
assertEquals(y, x);
y.clear();
assertTrue(y.isEmpty());
assertFalse(x.equals(y));
}
/**

View File

@ -625,7 +625,7 @@ public class ConcurrentSkipListSubMapTest extends JSR166TestCase {
}
/**
* A deserialized map equals original
* A deserialized/reserialized map equals original
*/
public void testSerialization() throws Exception {
NavigableMap x = map5();
@ -1299,7 +1299,7 @@ public class ConcurrentSkipListSubMapTest extends JSR166TestCase {
}
/**
* A deserialized map equals original
* A deserialized/reserialized map equals original
*/
public void testDescendingSerialization() throws Exception {
NavigableMap x = dmap5();

View File

@ -503,7 +503,7 @@ public class ConcurrentSkipListSubSetTest extends JSR166TestCase {
}
/**
* A deserialized serialized set has same elements
* A deserialized/reserialized set equals original
*/
public void testSerialization() throws Exception {
NavigableSet x = populatedSet(SIZE);
@ -1002,7 +1002,7 @@ public class ConcurrentSkipListSubSetTest extends JSR166TestCase {
}
/**
* A deserialized serialized set has same elements
* A deserialized/reserialized set equals original
*/
public void testDescendingSerialization() throws Exception {
NavigableSet x = dset5();

View File

@ -774,7 +774,7 @@ public class CopyOnWriteArrayListTest extends JSR166TestCase {
}
/**
* a deserialized serialized list is equal
* a deserialized/reserialized list equals original
*/
public void testSerialization() throws Exception {
List x = populatedArray(SIZE);

View File

@ -403,7 +403,7 @@ public class CopyOnWriteArraySetTest extends JSR166TestCase {
}
/**
* A deserialized serialized set is equal
* A deserialized/reserialized set equals original
*/
public void testSerialization() throws Exception {
Set x = populatedSet(SIZE);

View File

@ -89,7 +89,7 @@ public class DoubleAdderTest extends JSR166TestCase {
}
/**
* a deserialized serialized adder holds same value
* a deserialized/reserialized adder holds same value
*/
public void testSerialization() throws Exception {
DoubleAdder x = new DoubleAdder();

View File

@ -1142,53 +1142,6 @@ public class JSR166TestCase extends TestCase {
fail("timed out waiting for thread to enter thread state " + expected);
}
/**
* Checks that thread does not terminate within the default
* millisecond delay of {@code timeoutMillis()}.
* TODO: REMOVEME
*/
void assertThreadStaysAlive(Thread thread) {
assertThreadStaysAlive(thread, timeoutMillis());
}
/**
* Checks that thread does not terminate within the given millisecond delay.
* TODO: REMOVEME
*/
void assertThreadStaysAlive(Thread thread, long millis) {
try {
// No need to optimize the failing case via Thread.join.
delay(millis);
assertTrue(thread.isAlive());
} catch (InterruptedException fail) {
threadFail("Unexpected InterruptedException");
}
}
/**
* Checks that the threads do not terminate within the default
* millisecond delay of {@code timeoutMillis()}.
* TODO: REMOVEME
*/
void assertThreadsStayAlive(Thread... threads) {
assertThreadsStayAlive(timeoutMillis(), threads);
}
/**
* Checks that the threads do not terminate within the given millisecond delay.
* TODO: REMOVEME
*/
void assertThreadsStayAlive(long millis, Thread... threads) {
try {
// No need to optimize the failing case via Thread.join.
delay(millis);
for (Thread thread : threads)
assertTrue(thread.isAlive());
} catch (InterruptedException fail) {
threadFail("Unexpected InterruptedException");
}
}
/**
* Checks that future.get times out, with the default timeout of
* {@code timeoutMillis()}.

View File

@ -1800,7 +1800,7 @@ public class LinkedBlockingDequeTest extends JSR166TestCase {
}
/**
* A deserialized serialized deque has same elements in same order
* A deserialized/reserialized deque has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedDeque(SIZE);

View File

@ -823,7 +823,7 @@ public class LinkedBlockingQueueTest extends JSR166TestCase {
}
/**
* A deserialized serialized queue has same elements in same order
* A deserialized/reserialized queue has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);

View File

@ -674,7 +674,7 @@ public class LinkedTransferQueueTest extends JSR166TestCase {
}
/**
* A deserialized serialized queue has same elements in same order
* A deserialized/reserialized queue has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);

View File

@ -111,7 +111,7 @@ public class LongAdderTest extends JSR166TestCase {
}
/**
* a deserialized serialized adder holds same value
* a deserialized/reserialized adder holds same value
*/
public void testSerialization() throws Exception {
LongAdder x = new LongAdder();

View File

@ -686,7 +686,7 @@ public class PriorityBlockingQueueTest extends JSR166TestCase {
}
/**
* A deserialized serialized queue has same elements
* A deserialized/reserialized queue has same elements
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);

View File

@ -522,7 +522,7 @@ public class PriorityQueueTest extends JSR166TestCase {
}
/**
* A deserialized serialized queue has same elements
* A deserialized/reserialized queue has same elements
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);

View File

@ -557,7 +557,7 @@ public class SynchronousQueueTest extends JSR166TestCase {
}
/**
* a deserialized serialized queue is usable
* a deserialized/reserialized queue is usable
*/
public void testSerialization() {
final SynchronousQueue x = new SynchronousQueue();

View File

@ -260,8 +260,8 @@ public class ThreadLocalRandom8Test extends JSR166TestCase {
}
/**
* A deserialized ThreadLocalRandom is always identical to
* ThreadLocalRandom.current()
* A deserialized/reserialized ThreadLocalRandom is always
* identical to ThreadLocalRandom.current()
*/
public void testSerialization() {
assertSame(

View File

@ -1319,8 +1319,8 @@ public class ThreadPoolExecutorSubclassTest extends JSR166TestCase {
public void testMaximumPoolSizeIllegalArgumentException2() {
final ThreadPoolExecutor p =
new CustomTPE(2, 3,
LONG_DELAY_MS,
MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
LONG_DELAY_MS, MILLISECONDS,
new ArrayBlockingQueue<Runnable>(10));
try (PoolCleaner cleaner = cleaner(p)) {
try {
p.setMaximumPoolSize(-1);

View File

@ -623,7 +623,7 @@ public class TimeUnitTest extends JSR166TestCase {
}
/**
* a deserialized serialized unit is the same instance
* a deserialized/reserialized unit is the same instance
*/
public void testSerialization() throws Exception {
for (TimeUnit x : TimeUnit.values())

View File

@ -633,7 +633,7 @@ public class TreeMapTest extends JSR166TestCase {
}
/**
* A deserialized map equals original
* A deserialized/reserialized map equals original
*/
public void testSerialization() throws Exception {
NavigableMap x = map5();

View File

@ -549,7 +549,7 @@ public class TreeSetTest extends JSR166TestCase {
}
/**
* A deserialized serialized set has same elements
* A deserialized/reserialized set equals original
*/
public void testSerialization() throws Exception {
NavigableSet x = populatedSet(SIZE);

View File

@ -460,7 +460,7 @@ public class TreeSubMapTest extends JSR166TestCase {
}
/**
* A deserialized map equals original
* A deserialized/reserialized map equals original
*/
public void testSerialization() throws Exception {
NavigableMap x = map5();
@ -987,7 +987,7 @@ public class TreeSubMapTest extends JSR166TestCase {
}
/**
* A deserialized map equals original
* A deserialized/reserialized map equals original
*/
public void testDescendingSerialization() throws Exception {
NavigableMap x = dmap5();

View File

@ -500,7 +500,7 @@ public class TreeSubSetTest extends JSR166TestCase {
}
/**
* A deserialized serialized set has same elements
* A deserialized/reserialized set equals original
*/
public void testSerialization() throws Exception {
NavigableSet x = populatedSet(SIZE);
@ -988,7 +988,7 @@ public class TreeSubSetTest extends JSR166TestCase {
}
/**
* A deserialized serialized set has same elements
* A deserialized/reserialized set equals original
*/
public void testDescendingSerialization() throws Exception {
NavigableSet x = dset5();