Buggy code:
public class TopSpeedWindowing { private static final int NUM_CAR_EVENTS = 100 ; public static void main ( String [ ] args ) throws Exception { if ( ! ( TopSpeedWindowing . parseParameters ( args ) ) ) { return ; } final StreamExecutionEnvironment env = StreamExecutionEnvironment . getExecutionEnvironment ( ) ; @ SuppressWarnings ( { "rawtypes" , "serial" } ) DataStream < Tuple4 < Integer , Integer , Double , Long > > carData ; if ( TopSpeedWindowing . fileInput ) { carData = env . readTextFile ( TopSpeedWindowing . inputPath ) . map ( new TopSpeedWindowing . ParseCarData ( ) ) ; } else { carData = env . addSource ( TopSpeedWindowing . CarSource . create ( TopSpeedWindowing . numOfCars ) ) ; } <START_BUG> DataStream < Tuple4 < Integer , Integer , Double , Long > > topSpeeds = carData . groupBy ( 0 ) . window ( Time . of ( TopSpeedWindowing . evictionSec , new TopSpeedWindowing . CarTimestamp ( ) ) ) . every ( Delta . of ( TopSpeedWindowing . triggerMeters , new org . apache . flink . streaming . api . windowing . deltafunction . DeltaFunction < Tuple4 < Integer , Integer , Double , Long > > ( ) { <END_BUG> private static final long serialVersionUID = 1L ; @ Override public double getDelta ( Tuple4 < Integer , Integer , Double , Long > oldDataPoint , Tuple4 < Integer , Integer , Double , Long > newDataPoint ) { return ( newDataPoint . f2 ) - ( oldDataPoint . f2 ) ; } } , new Tuple4 < Integer , Integer , Double , Long > ( 0 , 0 , 0.0 , 0L ) ) ) . local ( ) . maxBy ( 1 ) . flatten ( ) ; if ( TopSpeedWindowing . fileOutput ) { topSpeeds . writeAsText ( TopSpeedWindowing . outputPath ) ; } else { topSpeeds . print ( ) ; } env . execute ( "CarTopSpeedWindowingExample" ) ; } private static class CarSource implements SourceFunction < Tuple4 < Integer , Integer , Double , Long > > { private static final long serialVersionUID = 1L ; private Integer [ ] speeds ; private Double [ ] distances ; private Random rand = new Random ( ) ; private volatile boolean isRunning = true ; private int counter ; private CarSource ( int numOfCars ) { } public static TopSpeedWindowing . CarSource create ( int cars ) { } @ Override public void run ( SourceContext < Tuple4 < Integer , Integer , Double , Long > > ctx ) throws Exception { } @ Override public void cancel ( ) { } } private static class ParseCarData extends RichMapFunction < String , Tuple4 < Integer , Integer , Double , Long > > { private static final long serialVersionUID = 1L ; @ Override public Tuple4 < Integer , Integer , Double , Long > map ( String record ) { } } private static class CarTimestamp implements Timestamp < Tuple4 < Integer , Integer , Double , Long > > { private static final long serialVersionUID = 1L ; @ Override public long getTimestamp ( Tuple4 < Integer , Integer , Double , Long > value ) { } } private static boolean fileInput = false ; private static boolean fileOutput = false ; private static int numOfCars = 2 ; private static int evictionSec = 10 ; private static double triggerMeters = 50 ; private static String inputPath ; private static String outputPath ; private static boolean parseParameters ( String [ ] args ) { } }

Fix:
DataStream < Tuple4 < Integer , Integer , Double , Long > > topSpeeds = carData . groupBy ( 0 ) . window ( Time . of ( ( ( TopSpeedWindowing . evictionSec ) * 1000 ) , new TopSpeedWindowing . CarTimestamp ( ) ) ) . every ( Delta . of ( TopSpeedWindowing . triggerMeters , new org . apache . flink . streaming . api . windowing . deltafunction . DeltaFunction < Tuple4 < Integer , Integer , Double , Long > > ( ) {