Test Dataflow with DirectRunner and got lots of verifyUnmodifiedThrowingCheckedExceptions

It may help to ensure that all serialized values have proper equals() implementations since SerializableCoder expects them:

The structural value of the object is the object itself. The SerializableCoder should be only used for objects with a proper Object#equals implementation.

You can implement your own Coder for your POJOs. SerializableCoder does not guarantee a deterministic encoding according to docs:

SerializableCoder does not guarantee a deterministic encoding, as Java serialization may produce different binary encodings for two equivalent objects.

This article explains custom coders in details.


I had this same problem. I was using SerializableCoder for a class implementing Serializable, and my tests were failing because the PAssert() containsInAnyOrder() method was not using MyClass.equals() to evaluate object equality. The signature of my equals() method was:

public boolean equals(MyClass other) {...}

All I had to do to fix it was to define equals in terms of Object:

public boolean equals(Object other) {...}

This made the warnings go away, and made the tests pass.


Just add https://projectlombok.org/features/EqualsAndHashCode

@EqualsAndHashCode 
public class YourRecord implements Serializable {