zentol commented on a change in pull request #7061: [FLINK-10827][tests] Add test for duplicate() to SerializerTestBase URL: https://github.com/apache/flink/pull/7061#discussion_r232263454
########## File path: flink-core/src/test/java/org/apache/flink/api/common/typeutils/SerializerTestBase.java ########## @@ -526,6 +561,55 @@ public void write(DataInputView source, int numBytes) throws IOException { } } + /** + * Runner to test serializer duplication via concurrency. + * @param <T> type of the test elements. + */ + static class SerializerRunner<T> extends Thread { + final OneShotLatch startLatch; + final TypeSerializer<T> serializer; + final T[] testData; + final int iterations; + Exception failure; + + SerializerRunner(OneShotLatch startLatch, TypeSerializer<T> serializer, T[] testData, int iterations) { + this.startLatch = startLatch; + this.serializer = serializer; + this.testData = testData; + this.iterations = iterations; + this.failure = null; + } + + @Override + public void run() { + DataInputDeserializer dataInputDeserializer = new DataInputDeserializer(); + DataOutputSerializer dataOutputSerializer = new DataOutputSerializer(128); + try { + startLatch.await(); + for (int repeat = 0; repeat < iterations; ++repeat) { + for (T testItem : testData) { + serializer.serialize(testItem, dataOutputSerializer); + dataInputDeserializer.setBuffer( + dataOutputSerializer.getSharedBuffer(), + 0, + dataOutputSerializer.length()); + T serdeTestItem = serializer.deserialize(dataInputDeserializer); + T copySerdeTestItem = serializer.copy(serdeTestItem); + dataOutputSerializer.clear(); + Assert.assertEquals(testItem, copySerdeTestItem); + } + } + } catch (Exception ex) { Review comment: AssertionErrors (that are thrown by assertEquals) are not exceptions. https://docs.oracle.com/javase/7/docs/api/java/lang/AssertionError.html ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services