Program: 166573
Project: 166573
Buggy source:
/** 
 * Test full stack serialization for a TransactionManager migrating from DefaultSnapshotCodec to SnapshotCodecV3.
 */
@Test public void testDefaultToV3Migration() throws Exception {
  File testDir=tmpDir.newFolder("String_Node_Str");
  Configuration conf=new Configuration();
  conf.set(TxConstants.Persist.CFG_TX_SNAPHOT_CODEC_CLASSES,DefaultSnapshotCodec.class.getName());
  conf.set(TxConstants.Manager.CFG_TX_SNAPSHOT_LOCAL_DIR,testDir.getAbsolutePath());
  Injector injector=Guice.createInjector(new ConfigModule(conf),new DiscoveryModules().getSingleNodeModules(),new TransactionModules().getSingleNodeModules());
  TransactionManager txManager=injector.getInstance(TransactionManager.class);
  txManager.startAndWait();
  txManager.startLong();
  txManager.stopAndWait();
  TransactionStateStorage txStorage=injector.getInstance(TransactionStateStorage.class);
  txStorage.startAndWait();
  TransactionSnapshot snapshot=txStorage.getLatestSnapshot();
  assertNotNull(snapshot);
  assertEquals(1,snapshot.getInProgress().size());
  Map.Entry<Long,TransactionManager.InProgressTx> entry=snapshot.getInProgress().entrySet().iterator().next();
  assertNull(entry.getValue().getType());
  Configuration conf2=new Configuration();
  conf2.set(TxConstants.Manager.CFG_TX_SNAPSHOT_LOCAL_DIR,testDir.getAbsolutePath());
  conf2.setStrings(TxConstants.Persist.CFG_TX_SNAPHOT_CODEC_CLASSES,DefaultSnapshotCodec.class.getName(),SnapshotCodecV3.class.getName());
  Injector injector2=Guice.createInjector(new ConfigModule(conf2),new DiscoveryModules().getSingleNodeModules(),new TransactionModules().getSingleNodeModules());
  TransactionManager txManager2=injector2.getInstance(TransactionManager.class);
  txManager2.startAndWait();
  TransactionSnapshot snapshot2=txManager2.getCurrentState();
  assertEquals(1,snapshot2.getInProgress().size());
  Map.Entry<Long,TransactionManager.InProgressTx> inProgressTx=snapshot2.getInProgress().entrySet().iterator().next();
  assertEquals(TransactionType.LONG,inProgressTx.getValue().getType());
  txManager2.stopAndWait();
  TransactionStateStorage txStorage2=injector2.getInstance(TransactionStateStorage.class);
  txStorage2.startAndWait();
  TransactionSnapshot snapshot3=txStorage2.getLatestSnapshot();
  assertEquals(snapshot2.getInProgress(),snapshot3.getInProgress());
  assertEquals(snapshot2,snapshot3);
}

Fixed version (ground truth):
/** 
 * Test full stack serialization for a TransactionManager migrating from DefaultSnapshotCodec to SnapshotCodecV3.
 */
@Test public void testDefaultToV3Migration() throws Exception {
  File testDir=tmpDir.newFolder("String_Node_Str");
  Configuration conf=new Configuration();
  conf.set(TxConstants.Persist.CFG_TX_SNAPHOT_CODEC_CLASSES,DefaultSnapshotCodec.class.getName());
  conf.set(TxConstants.Manager.CFG_TX_SNAPSHOT_LOCAL_DIR,testDir.getAbsolutePath());
  Injector injector=Guice.createInjector(new ConfigModule(conf),new DiscoveryModules().getSingleNodeModules(),new TransactionModules().getSingleNodeModules());
  TransactionManager txManager=injector.getInstance(TransactionManager.class);
  txManager.startAndWait();
  txManager.startLong();
  txManager.stopAndWait();
  TransactionStateStorage txStorage=injector.getInstance(TransactionStateStorage.class);
  txStorage.startAndWait();
  TransactionSnapshot snapshot=txStorage.getLatestSnapshot();
  assertNotNull(snapshot);
  assertEquals(1,snapshot.getInProgress().size());
  Map.Entry<Long,TransactionManager.InProgressTx> entry=snapshot.getInProgress().entrySet().iterator().next();
  assertNull(entry.getValue().getType());
  txStorage.stopAndWait();
  Configuration conf2=new Configuration();
  conf2.set(TxConstants.Manager.CFG_TX_SNAPSHOT_LOCAL_DIR,testDir.getAbsolutePath());
  conf2.setStrings(TxConstants.Persist.CFG_TX_SNAPHOT_CODEC_CLASSES,DefaultSnapshotCodec.class.getName(),SnapshotCodecV3.class.getName());
  Injector injector2=Guice.createInjector(new ConfigModule(conf2),new DiscoveryModules().getSingleNodeModules(),new TransactionModules().getSingleNodeModules());
  TransactionManager txManager2=injector2.getInstance(TransactionManager.class);
  txManager2.startAndWait();
  TransactionSnapshot snapshot2=txManager2.getCurrentState();
  assertEquals(1,snapshot2.getInProgress().size());
  Map.Entry<Long,TransactionManager.InProgressTx> inProgressTx=snapshot2.getInProgress().entrySet().iterator().next();
  assertEquals(TransactionType.LONG,inProgressTx.getValue().getType());
  txManager2.stopAndWait();
  TransactionStateStorage txStorage2=injector2.getInstance(TransactionStateStorage.class);
  txStorage2.startAndWait();
  TransactionSnapshot snapshot3=txStorage2.getLatestSnapshot();
  assertEquals(snapshot2.getInProgress(),snapshot3.getInProgress());
  assertEquals(snapshot2,snapshot3);
  txStorage2.stopAndWait();
}