Program: 6349
Project: 6349
Buggy source:
/** 
 * @param datasetMap if not null, this test method will save the instances of a and b into the map.
 */
protected void testDatasetCache(@Nullable Map<String,TestDataset> datasetMap) throws IOException, DatasetManagementException, TransactionFailureException {
  TestDataset a=cache.getDataset("String_Node_Str");
  TestDataset a1=cache.getDataset("String_Node_Str");
  TestDataset a2=cache.getDataset("String_Node_Str",A_ARGUMENTS);
  Assert.assertSame(a,a1);
  Assert.assertSame(a,a2);
  TestDataset b=cache.getDataset("String_Node_Str",B_ARGUMENTS);
  TestDataset b1=cache.getDataset("String_Node_Str",B_ARGUMENTS);
  Assert.assertSame(b,b1);
  Assert.assertEquals(2,a.getArguments().size());
  Assert.assertEquals("String_Node_Str",a.getKey());
  Assert.assertEquals("String_Node_Str",a.getValue());
  Assert.assertEquals("String_Node_Str",b.getKey());
  Assert.assertEquals("String_Node_Str",b.getValue());
  List<TestDataset> txAwares=getTxAwares();
  Assert.assertTrue(txAwares.isEmpty());
  TransactionContext txContext=cache.newTransactionContext();
  txAwares=getTxAwares();
  Assert.assertEquals(2,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  txContext.start();
  String sysPropA=System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  Assert.assertNotNull(sysPropA);
  String sysPropB=System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  Assert.assertNotNull(sysPropB);
  Assert.assertNotEquals(0L,Long.parseLong(sysPropA));
  Assert.assertEquals(sysPropA,sysPropB);
  TestDataset c=cache.getDataset("String_Node_Str",C_ARGUMENTS);
  String sysPropC=System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  Assert.assertNotNull(sysPropC);
  Assert.assertEquals(sysPropA,sysPropC);
  Assert.assertEquals("String_Node_Str",c.getKey());
  Assert.assertEquals("String_Node_Str",c.getValue());
  txAwares=getTxAwares();
  Assert.assertEquals(3,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  Assert.assertSame(c,txAwares.get(2));
  cache.discardDataset(b);
  cache.discardDataset(c);
  Assert.assertNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  Assert.assertNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  txAwares=getTxAwares();
  Assert.assertEquals(2,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  TestDataset b3=cache.getDataset("String_Node_Str",B_ARGUMENTS);
  TestDataset c1=cache.getDataset("String_Node_Str",C_ARGUMENTS);
  Assert.assertSame(b3,b);
  Assert.assertSame(c1,c);
  txAwares=getTxAwares();
  Assert.assertEquals(3,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  Assert.assertSame(c,txAwares.get(2));
  cache.discardDataset(b);
  cache.discardDataset(c);
  Assert.assertNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  Assert.assertNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  txAwares=getTxAwares();
  Assert.assertEquals(2,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  txContext.abort();
  Assert.assertNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  Assert.assertNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  Assert.assertNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  txAwares=getTxAwares();
  Assert.assertEquals(2,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  Assert.assertNotNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  Assert.assertNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  txContext.start();
  Assert.assertNotNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  Assert.assertNotNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  Assert.assertNull(System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  cache.discardDataset(c);
  c1=cache.getDataset("String_Node_Str",C_ARGUMENTS);
  Assert.assertNotSame(c,c1);
  cache.discardDataset(c1);
  txContext.finish();
  cache.dismissTransactionContext();
  Assert.assertTrue(getTxAwares().isEmpty());
  txContext=cache.newTransactionContext();
  txContext.start();
  Assert.assertNotNull(txContext.getCurrentTransaction());
  String currentTx=Long.toString(txContext.getCurrentTransaction().getWritePointer());
  Assert.assertEquals(currentTx,System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  Assert.assertEquals(currentTx,System.getProperty(TestDataset.generateSystemProperty("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")));
  txContext.abort();
  if (datasetMap != null) {
    datasetMap.put("String_Node_Str",a);
    datasetMap.put("String_Node_Str",b);
  }
}

Fixed version (ground truth):
/** 
 * @param datasetMap if not null, this test method will save the instances of a and b into the map.
 */
protected void testDatasetCache(@Nullable Map<String,TestDataset> datasetMap) throws IOException, DatasetManagementException, TransactionFailureException {
  TestDataset a=cache.getDataset("String_Node_Str");
  TestDataset a1=cache.getDataset("String_Node_Str");
  TestDataset a2=cache.getDataset("String_Node_Str",A_ARGUMENTS);
  Assert.assertSame(a,a1);
  Assert.assertSame(a,a2);
  TestDataset b=cache.getDataset("String_Node_Str",B_ARGUMENTS);
  TestDataset b1=cache.getDataset("String_Node_Str",B_ARGUMENTS);
  Assert.assertSame(b,b1);
  Assert.assertEquals(2,a.getArguments().size());
  Assert.assertEquals("String_Node_Str",a.getKey());
  Assert.assertEquals("String_Node_Str",a.getValue());
  Assert.assertEquals("String_Node_Str",b.getKey());
  Assert.assertEquals("String_Node_Str",b.getValue());
  List<TestDataset> txAwares=getTxAwares();
  Assert.assertTrue(txAwares.isEmpty());
  TransactionContext txContext=cache.newTransactionContext();
  txAwares=getTxAwares();
  Assert.assertEquals(2,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  txContext.start();
  Assert.assertNotNull(a.getCurrentTransaction());
  Assert.assertNotEquals(0L,a.getCurrentTransaction().getWritePointer());
  Assert.assertEquals(a.getCurrentTransaction(),b.getCurrentTransaction());
  TestDataset c=cache.getDataset("String_Node_Str",C_ARGUMENTS);
  Assert.assertEquals(a.getCurrentTransaction(),c.getCurrentTransaction());
  Assert.assertEquals("String_Node_Str",c.getKey());
  Assert.assertEquals("String_Node_Str",c.getValue());
  txAwares=getTxAwares();
  Assert.assertEquals(3,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  Assert.assertSame(c,txAwares.get(2));
  cache.discardDataset(b);
  cache.discardDataset(c);
  Assert.assertFalse(b.isClosed());
  Assert.assertFalse(c.isClosed());
  txAwares=getTxAwares();
  Assert.assertEquals(2,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  TestDataset b3=cache.getDataset("String_Node_Str",B_ARGUMENTS);
  TestDataset c1=cache.getDataset("String_Node_Str",C_ARGUMENTS);
  Assert.assertSame(b3,b);
  Assert.assertSame(c1,c);
  txAwares=getTxAwares();
  Assert.assertEquals(3,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  Assert.assertSame(c,txAwares.get(2));
  cache.discardDataset(b);
  cache.discardDataset(c);
  Assert.assertFalse(b.isClosed());
  Assert.assertFalse(c.isClosed());
  txAwares=getTxAwares();
  Assert.assertEquals(2,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  txContext.abort();
  Assert.assertNull(a.getCurrentTransaction());
  Assert.assertNull(b.getCurrentTransaction());
  Assert.assertNull(c.getCurrentTransaction());
  txAwares=getTxAwares();
  Assert.assertEquals(2,txAwares.size());
  Assert.assertSame(a,txAwares.get(0));
  Assert.assertSame(b,txAwares.get(1));
  Assert.assertTrue(c.isClosed());
  Assert.assertFalse(b.isClosed());
  txContext.start();
  Assert.assertNotNull(a.getCurrentTransaction());
  Assert.assertEquals(a.getCurrentTransaction(),b.getCurrentTransaction());
  Assert.assertNull(c.getCurrentTransaction());
  cache.discardDataset(c);
  c1=cache.getDataset("String_Node_Str",C_ARGUMENTS);
  Assert.assertNotSame(c,c1);
  cache.discardDataset(c1);
  txContext.finish();
  cache.dismissTransactionContext();
  Assert.assertTrue(getTxAwares().isEmpty());
  txContext=cache.newTransactionContext();
  txContext.start();
  Assert.assertNotNull(txContext.getCurrentTransaction());
  Assert.assertEquals(txContext.getCurrentTransaction(),a.getCurrentTransaction());
  Assert.assertEquals(txContext.getCurrentTransaction(),b.getCurrentTransaction());
  txContext.abort();
  if (datasetMap != null) {
    datasetMap.put("String_Node_Str",a);
    datasetMap.put("String_Node_Str",b);
  }
}