Github user uce commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2116#discussion_r67514718
  
    --- Diff: 
flink-tests/src/test/java/org/apache/flink/test/javaApiOperators/CoGroupITCase.java
 ---
    @@ -334,6 +335,124 @@ public void 
testCoGroupWithMultipleKeyFieldsWithKeyExtractor() throws Exception
                compareResultAsTuples(result, expected);
        }
     
    +   @Test
    +   public void 
testCoGroupWithMultipleKeyFieldsWithInnerClassKeyExtractorWithClosureCleaner() 
throws Exception {
    +           /*
    +            * CoGroup with multiple key fields, test working closure 
cleaner for inner classes
    +            */
    +
    +           final ExecutionEnvironment env = 
ExecutionEnvironment.getExecutionEnvironment();
    +
    +           DataSet<Tuple5<Integer, Long, Integer, String, Long>> ds1 = 
CollectionDataSets.get5TupleDataSet(env);
    +           DataSet<Tuple3<Integer, Long, String>> ds2 = 
CollectionDataSets.get3TupleDataSet(env);
    +
    +           DataSet<Tuple3<Integer, Long, String>> coGrouped = 
ds1.coGroup(ds2).
    +                           where(new KeySelector<Tuple5<Integer, Long, 
Integer, String, Long>,
    +                                           Tuple2<Integer, Long>>() {
    +                                   @Override
    +                                   public Tuple2<Integer, Long> 
getKey(Tuple5<Integer, Long, Integer, String, Long> t) throws Exception {
    +                                           return new Tuple2<Integer, 
Long>(t.f0, t.f4);
    +                                   }
    +                           }).
    +                           equalTo(new 
KeySelector<Tuple3<Integer,Long,String>, Tuple2<Integer, Long>>() {
    +
    +                                   @Override
    +                                   public Tuple2<Integer, Long> 
getKey(Tuple3<Integer,Long,String> t) {
    +                                           return new Tuple2<Integer, 
Long>(t.f0, t.f1);
    +                                   }
    +                           }).
    +                           with(new CoGroupFunction<Tuple5<Integer, Long, 
Integer, String, Long>, Tuple3<Integer, Long, String>, Tuple3<Integer, Long, 
String>>() {
    +                                   @Override
    +                                   public void 
coGroup(Iterable<Tuple5<Integer, Long, Integer, String, Long>> first,
    +                                                       
Iterable<Tuple3<Integer, Long, String>> second,
    +                                                       
Collector<Tuple3<Integer, Long, String>> out)
    +                                   {
    +                                           List<String> strs = new 
ArrayList<String>();
    +
    +                                           for (Tuple5<Integer, Long, 
Integer, String, Long> t : first) {
    +                                                   strs.add(t.f3);
    +                                           }
    +
    +                                           for(Tuple3<Integer, Long, 
String> t : second) {
    +                                                   for(String s : strs) {
    +                                                           out.collect(new 
Tuple3<Integer, Long, String>(t.f0, t.f1, s));
    +                                                   }
    +                                           }
    +                                   }
    +                           });
    +
    +           List<Tuple3<Integer, Long, String>> result = 
coGrouped.collect();
    +
    +           String expected = "1,1,Hallo\n" +
    +                           "2,2,Hallo Welt\n" +
    +                           "3,2,Hallo Welt wie gehts?\n" +
    +                           "3,2,ABC\n" +
    +                           "5,3,HIJ\n" +
    +                           "5,3,IJK\n";
    +
    +           compareResultAsTuples(result, expected);
    +   }
    +
    +   @Test(expected = InvalidProgramException.class)
    --- End diff --
    
    Would make sense to test this in a more specific way, e.g. wrap in `try { 
... } catch (InvalidProgramException e) { }` and check that the root cause of 
`e` is `NotSerializableException`. Otherwise, a not respected closure cleaner 
usage flag might be hidden by another exception. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to