DefaultStatefulStreamCodec extends Kryo implements StatefulStreamCodec<T> { @Override public DefaultStatefulStreamCodec<T> newInstance() { try { return getClass().newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException("Unable to create new stateful streamcodec object", e); } } @SuppressWarnings("OverridableMethodCallInConstructor")  DefaultStatefulStreamCodec(); @Override T fromDataStatePair(DataStatePair dspair); @Override DataStatePair toDataStatePair(T o); @Override int getPartition(T o); @Override void resetState(); @Override Object fromByteArray(Slice fragment); @Override Slice toByteArray(T o); @Override DefaultStatefulStreamCodec<T> newInstance();  }
@Test public void testNewInstanceMethod() { NoNewInstanceStatefulStreamCodec codec = new NoNewInstanceStatefulStreamCodec(); DefaultStatefulStreamCodec newCodec = codec.newInstance(); Assert.assertNotEquals("Codec and newCodec are not same ", codec, newCodec); Assert.assertEquals("Class of codec and newCodec is same ", newCodec.getClass(), codec.getClass()); }