Program: 172226
Project: 172226
Buggy source:
public void testTransactionalCacheWithSingleTxn() throws Throwable {
  String newGlobalOne="String_Node_Str";
  String newGlobalTwo="String_Node_Str";
  String newGlobalThree="String_Node_Str";
  String updatedTxnThree="String_Node_Str";
  backingCache.put(newGlobalOne,newGlobalOne);
  backingCache.put(newGlobalTwo,newGlobalTwo);
  backingCache.put(newGlobalThree,newGlobalThree);
  TransactionService transactionService=serviceRegistry.getTransactionService();
  UserTransaction txn=transactionService.getUserTransaction();
  try {
    txn.begin();
    transactionalCache.remove(newGlobalOne);
    assertFalse("String_Node_Str",transactionalCache.contains(newGlobalOne));
    assertNull("String_Node_Str",transactionalCache.get(newGlobalOne));
    assertTrue("String_Node_Str",backingCache.contains(newGlobalOne));
    transactionalCache.put(updatedTxnThree,"String_Node_Str");
    assertEquals("String_Node_Str","String_Node_Str",transactionalCache.get(updatedTxnThree));
    assertFalse("String_Node_Str",backingCache.contains(updatedTxnThree));
    Collection<String> transactionalKeys=transactionalCache.getKeys();
    assertFalse("String_Node_Str",transactionalKeys.contains(newGlobalOne));
    assertTrue("String_Node_Str",transactionalKeys.contains(updatedTxnThree));
    PostCommitCacheUser listener=new PostCommitCacheUser(transactionalCache,updatedTxnThree);
    AlfrescoTransactionSupport.bindListener(listener);
    txn.commit();
    if (listener.e != null) {
      throw listener.e;
    }
    assertFalse("String_Node_Str",backingCache.contains(newGlobalOne));
    assertNull("String_Node_Str",backingCache.get(newGlobalOne));
    assertEquals("String_Node_Str","String_Node_Str",backingCache.get(updatedTxnThree));
    assertEquals("String_Node_Str","String_Node_Str",transactionalCache.get(updatedTxnThree));
  }
 catch (  Throwable e) {
    if (txn.getStatus() == Status.STATUS_ACTIVE) {
      txn.rollback();
    }
    throw e;
  }
}

Fixed version (ground truth):
public void testTransactionalCacheWithSingleTxn() throws Throwable {
  String newGlobalOne="String_Node_Str";
  String newGlobalTwo="String_Node_Str";
  String newGlobalThree="String_Node_Str";
  String updatedTxnThree="String_Node_Str";
  String updatedTxnFour="String_Node_Str";
  backingCache.put(newGlobalOne,newGlobalOne);
  backingCache.put(newGlobalTwo,newGlobalTwo);
  backingCache.put(newGlobalThree,newGlobalThree);
  TransactionService transactionService=serviceRegistry.getTransactionService();
  UserTransaction txn=transactionService.getUserTransaction();
  try {
    txn.begin();
    transactionalCache.remove(newGlobalOne);
    assertFalse("String_Node_Str",transactionalCache.contains(newGlobalOne));
    assertNull("String_Node_Str",transactionalCache.get(newGlobalOne));
    assertTrue("String_Node_Str",backingCache.contains(newGlobalOne));
    transactionalCache.put(updatedTxnThree,"String_Node_Str");
    assertEquals("String_Node_Str","String_Node_Str",transactionalCache.get(updatedTxnThree));
    assertFalse("String_Node_Str",backingCache.contains(updatedTxnThree));
    Collection<String> transactionalKeys=transactionalCache.getKeys();
    assertFalse("String_Node_Str",transactionalKeys.contains(newGlobalOne));
    assertTrue("String_Node_Str",transactionalKeys.contains(updatedTxnThree));
    PostCommitCacheReader listenerReader=new PostCommitCacheReader(transactionalCache,updatedTxnThree);
    AlfrescoTransactionSupport.bindListener(listenerReader);
    PostCommitCacheWriter listenerWriter=new PostCommitCacheWriter(transactionalCache,updatedTxnFour,"String_Node_Str");
    AlfrescoTransactionSupport.bindListener(listenerWriter);
    txn.commit();
    if (listenerReader.e != null) {
      throw listenerReader.e;
    }
    if (listenerWriter.e != null) {
      throw listenerWriter.e;
    }
    assertFalse("String_Node_Str",backingCache.contains(newGlobalOne));
    assertNull("String_Node_Str",backingCache.get(newGlobalOne));
    assertEquals("String_Node_Str","String_Node_Str",backingCache.get(updatedTxnThree));
    assertEquals("String_Node_Str","String_Node_Str",transactionalCache.get(updatedTxnThree));
  }
 catch (  Throwable e) {
    if (txn.getStatus() == Status.STATUS_ACTIVE) {
      txn.rollback();
    }
    throw e;
  }
}