Github user greghogan commented on the issue:

    https://github.com/apache/flink/pull/5047
  
    This change doesn't work since `WordWithCount` needs to be a POJO which 
requires a default or no-args constructor and non-final public attributes or 
getters/setters. Since the type is not a POJO the `TypeExtractor` falls back to 
`GenericType`, which cannot be used as a key type as noted in the error message:
    
    ~~~~
    Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.949 sec 
<<< FAILURE! - in 
org.apache.flink.streaming.test.socket.SocketWindowWordCountITCase
    
testJavaProgram(org.apache.flink.streaming.test.socket.SocketWindowWordCountITCase)
  Time elapsed: 0.045 sec  <<< ERROR!
    org.apache.flink.api.common.InvalidProgramException: This type 
(GenericType<org.apache.flink.streaming.examples.socket.SocketWindowWordCount.WordWithCount>)
 cannot be used as key.
        at 
org.apache.flink.api.common.operators.Keys$ExpressionKeys.<init>(Keys.java:330)
        at 
org.apache.flink.streaming.api.datastream.DataStream.keyBy(DataStream.java:295)
        at 
org.apache.flink.streaming.examples.socket.SocketWindowWordCount.main(SocketWindowWordCount.java:79)
        at 
org.apache.flink.streaming.test.socket.SocketWindowWordCountITCase.testJavaProgram(SocketWindowWordCountITCase.java:65)
    ~~~~


---

Reply via email to