When deciding if a class conforms to POJO using the type extractor Flink checks that the class implements a setter and getter method. For the setter method Flink makes the assertion that the return type is `Void`. This is an issue if using a case class as often the return type of a case class setter is a copy of the objects class. Consider the following case class:
This class will be identified as not being valid POJO although getter (generated) and setter methods are provided because the return type of the setter is not void.
This issue discourages immutabilaty and makes the usage of case classes not possible without falling back to Kryo Serializer.
The issue is located in https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java on line 1806. Here is a permalink to the line
A copy of the if check is here
I believe the
should be modified to
This will allow for case class setters which return copies of the object enabling to use case classes. This allows us to maintain immutability without being forced to fall back to the Kryo Serializer.