RFR 8031428 CountTest causes lambda Ser/Derialization tests to fail

2014-01-10 Thread Paul Sandoz
Hi,

A small tweak is required to a recent Stream-based test i added to stop some 
internal lambda-based ser/derialization (SAND) tests barfing since the test is 
hostile to ser/derialization, and infact i should have probably written the 
test like below in the first place.

Kumar has verified it fixes the SAND test failures.

Paul.

https://bugs.openjdk.java.net/browse/JDK-8031428

diff -r e332a6819993 
test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java
--- 
a/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java  
Fri Jan 10 08:22:00 2014 +0100
+++ 
b/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java  
Fri Jan 10 10:58:06 2014 +0100
@@ -29,7 +29,6 @@
 
 package org.openjdk.tests.java.util.stream;
 
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.DoubleStream;
 import java.util.stream.DoubleStreamTestDataProvider;
 import java.util.stream.IntStream;
@@ -47,45 +46,41 @@
 
 @Test(dataProvider = StreamTestDataInteger, dataProviderClass = 
StreamTestDataProvider.class)
 public void testOps(String name, TestData.OfRefInteger data) {
-AtomicLong expectedCount = new AtomicLong();
-data.stream().forEach(e - expectedCount.incrementAndGet());
+long expectedCount = data.size();
 
 withData(data).
 terminal(Stream::count).
-expectedResult(expectedCount.get()).
+expectedResult(expectedCount).
 exercise();
 }
 
 @Test(dataProvider = IntStreamTestData, dataProviderClass = 
IntStreamTestDataProvider.class)
 public void testOps(String name, TestData.OfInt data) {
-AtomicLong expectedCount = new AtomicLong();
-data.stream().forEach(e - expectedCount.incrementAndGet());
+long expectedCount = data.size();
 
 withData(data).
 terminal(IntStream::count).
-expectedResult(expectedCount.get()).
+expectedResult(expectedCount).
 exercise();
 }
 
 @Test(dataProvider = LongStreamTestData, dataProviderClass = 
LongStreamTestDataProvider.class)
 public void testOps(String name, TestData.OfLong data) {
-AtomicLong expectedCount = new AtomicLong();
-data.stream().forEach(e - expectedCount.incrementAndGet());
+long expectedCount = data.size();
 
 withData(data).
 terminal(LongStream::count).
-expectedResult(expectedCount.get()).
+expectedResult(expectedCount).
 exercise();
 }
 
 @Test(dataProvider = DoubleStreamTestData, dataProviderClass = 
DoubleStreamTestDataProvider.class)
 public void testOps(String name, TestData.OfDouble data) {
-AtomicLong expectedCount = new AtomicLong();
-data.stream().forEach(e - expectedCount.incrementAndGet());
+long expectedCount = data.size();
 
 withData(data).
 terminal(DoubleStream::count).
-expectedResult(expectedCount.get()).
+expectedResult(expectedCount).
 exercise();
 }
 }


Re: RFR 8031428 CountTest causes lambda Ser/Derialization tests to fail

2014-01-10 Thread Chris Hegarty

Looks fine to me. I don't think AtomicLong was ever needed here.

-Chris.

On 10/01/14 10:01, Paul Sandoz wrote:

Hi,

A small tweak is required to a recent Stream-based test i added to stop some 
internal lambda-based ser/derialization (SAND) tests barfing since the test is 
hostile to ser/derialization, and infact i should have probably written the 
test like below in the first place.

Kumar has verified it fixes the SAND test failures.

Paul.

https://bugs.openjdk.java.net/browse/JDK-8031428

diff -r e332a6819993 
test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java
--- 
a/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java  
Fri Jan 10 08:22:00 2014 +0100
+++ 
b/test/java/util/stream/test/org/openjdk/tests/java/util/stream/CountTest.java  
Fri Jan 10 10:58:06 2014 +0100
@@ -29,7 +29,6 @@

  package org.openjdk.tests.java.util.stream;

-import java.util.concurrent.atomic.AtomicLong;
  import java.util.stream.DoubleStream;
  import java.util.stream.DoubleStreamTestDataProvider;
  import java.util.stream.IntStream;
@@ -47,45 +46,41 @@

  @Test(dataProvider = StreamTestDataInteger, dataProviderClass = 
StreamTestDataProvider.class)
  public void testOps(String name, TestData.OfRefInteger data) {
-AtomicLong expectedCount = new AtomicLong();
-data.stream().forEach(e - expectedCount.incrementAndGet());
+long expectedCount = data.size();

  withData(data).
  terminal(Stream::count).
-expectedResult(expectedCount.get()).
+expectedResult(expectedCount).
  exercise();
  }

  @Test(dataProvider = IntStreamTestData, dataProviderClass = 
IntStreamTestDataProvider.class)
  public void testOps(String name, TestData.OfInt data) {
-AtomicLong expectedCount = new AtomicLong();
-data.stream().forEach(e - expectedCount.incrementAndGet());
+long expectedCount = data.size();

  withData(data).
  terminal(IntStream::count).
-expectedResult(expectedCount.get()).
+expectedResult(expectedCount).
  exercise();
  }

  @Test(dataProvider = LongStreamTestData, dataProviderClass = 
LongStreamTestDataProvider.class)
  public void testOps(String name, TestData.OfLong data) {
-AtomicLong expectedCount = new AtomicLong();
-data.stream().forEach(e - expectedCount.incrementAndGet());
+long expectedCount = data.size();

  withData(data).
  terminal(LongStream::count).
-expectedResult(expectedCount.get()).
+expectedResult(expectedCount).
  exercise();
  }

  @Test(dataProvider = DoubleStreamTestData, dataProviderClass = 
DoubleStreamTestDataProvider.class)
  public void testOps(String name, TestData.OfDouble data) {
-AtomicLong expectedCount = new AtomicLong();
-data.stream().forEach(e - expectedCount.incrementAndGet());
+long expectedCount = data.size();

  withData(data).
  terminal(DoubleStream::count).
-expectedResult(expectedCount.get()).
+expectedResult(expectedCount).
  exercise();
  }
  }



Re: RFR 8031428 CountTest causes lambda Ser/Derialization tests to fail

2014-01-10 Thread Paul Sandoz
On Jan 10, 2014, at 12:48 PM, Chris Hegarty chris.hega...@oracle.com wrote:
 Looks fine to me.

Thanks.


 I don't think AtomicLong was ever needed here.
 

It was crudely used as a holder of the count, since captured refs are 
(effectively) final, and not for it's concurrent properties as i wanted to 
avoid using any higher-level operations such as sum().

Paul.