CombineFnUtil { public static <K, InputT, AccumT, OutputT> CombineFn<InputT, AccumT, OutputT> bindContext( CombineFnWithContext<InputT, AccumT, OutputT> combineFn, StateContext<?> stateContext) { Context context = CombineContextFactory.createFromStateContext(stateContext); return new NonSerializableBoundedCombineFn<>(combineFn, context); }  static CombineFn<InputT, AccumT, OutputT> bindContext(
      CombineFnWithContext<InputT, AccumT, OutputT> combineFn, StateContext<?> stateContext); static CombineFnWithContext<InputT, AccumT, OutputT> toFnWithContext(
          GlobalCombineFn<InputT, AccumT, OutputT> globalCombineFn);  }
@Test public void testNonSerializable() throws Exception { expectedException.expect(NotSerializableException.class); expectedException.expectMessage( "Cannot serialize the CombineFn resulting from CombineFnUtil.bindContext."); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(buffer); oos.writeObject(CombineFnUtil.bindContext(mockCombineFn, StateContexts.nullContext())); }