nus-yam/ex-repair huggingface dataset:
Program: 176154
Project: 176154
Buggy source:
@Test public void test(){
  try {
    KsDef ksDef=CassandraCli.client.describe_keyspace("String_Node_Str");
    Assert.assertNotNull(ksDef);
    Assert.assertEquals(16,ksDef.getCf_defsSize());
    int count=0;
    for (    CfDef cfDef : ksDef.cf_defs) {
      if (cfDef.getName().equals("String_Node_Str")) {
        Assert.assertTrue(cfDef.getColumn_type().equals("String_Node_Str"));
        Assert.assertTrue(cfDef.getDefault_validation_class().equals(CounterColumnType.class.getName()));
        count++;
        continue;
      }
      if (cfDef.getName().equals("String_Node_Str")) {
        Assert.assertTrue(cfDef.getColumn_type().equals("String_Node_Str"));
        Assert.assertTrue(cfDef.getDefault_validation_class().equals(CounterColumnType.class.getName()));
        count++;
      }
 else       if (!cfDef.getName().equals("String_Node_Str") && !cfDef.getName().equals("String_Node_Str")) {
        Assert.assertTrue(cfDef.getColumn_type().equals("String_Node_Str"));
        List<ColumnDef> columnDefs=cfDef.getColumn_metadata();
        Assert.assertEquals(1,columnDefs.size());
        count++;
      }
    }
    Assert.assertEquals(14,count);
  }
 catch (  NotFoundException e) {
    e.printStackTrace();
  }
catch (  InvalidRequestException e) {
    e.printStackTrace();
  }
catch (  TException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Test public void test(){
  try {
    KsDef ksDef=CassandraCli.client.describe_keyspace("String_Node_Str");
    Assert.assertNotNull(ksDef);
    Assert.assertEquals(18,ksDef.getCf_defsSize());
    int count=0;
    for (    CfDef cfDef : ksDef.cf_defs) {
      if (cfDef.getName().equals("String_Node_Str")) {
        Assert.assertTrue(cfDef.getColumn_type().equals("String_Node_Str"));
        Assert.assertTrue(cfDef.getDefault_validation_class().equals(CounterColumnType.class.getName()));
        count++;
        continue;
      }
      if (cfDef.getName().equals("String_Node_Str")) {
        Assert.assertTrue(cfDef.getColumn_type().equals("String_Node_Str"));
        Assert.assertTrue(cfDef.getDefault_validation_class().equals(CounterColumnType.class.getName()));
        count++;
      }
 else       if (!cfDef.getName().equals("String_Node_Str") && !cfDef.getName().equals("String_Node_Str")) {
        Assert.assertTrue(cfDef.getColumn_type().equals("String_Node_Str"));
        List<ColumnDef> columnDefs=cfDef.getColumn_metadata();
        Assert.assertEquals(1,columnDefs.size());
        count++;
      }
    }
    Assert.assertEquals(14,count);
  }
 catch (  NotFoundException e) {
    e.printStackTrace();
  }
catch (  InvalidRequestException e) {
    e.printStackTrace();
  }
catch (  TException e) {
    e.printStackTrace();
  }
}
Program: 176155
Project: 176155
Buggy source:
@Override public <E>List<E> findAll(Class<E> entityClass,String[] columnsToSelect,Object... rowIds){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entityClass);
  if (rowIds == null) {
    return null;
  }
  List results;
  try {
    results=handler.readAll(entityMetadata.getSchema(),entityMetadata.getEntityClazz(),entityMetadata,Arrays.asList(rowIds),entityMetadata.getRelationNames());
  }
 catch (  IOException ioex) {
    log.error("String_Node_Str",ioex);
    throw new KunderaException(ioex);
  }
  return results;
}

Fixed version (ground truth):
@Override public <E>List<E> findAll(Class<E> entityClass,String[] columnsToSelect,Object... rowIds){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entityClass);
  if (rowIds == null) {
    return null;
  }
  List results=new ArrayList<E>();
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(entityMetadata.getPersistenceUnit());
  EntityType entityType=metaModel.entity(entityClass);
  List<AbstractManagedType> subManagedType=((AbstractManagedType)entityType).getSubManagedType();
  try {
    if (!subManagedType.isEmpty()) {
      for (      AbstractManagedType subEntity : subManagedType) {
        EntityMetadata subEntityMetadata=KunderaMetadataManager.getEntityMetadata(subEntity.getJavaType());
        results=handler.readAll(subEntityMetadata.getSchema(),subEntityMetadata.getEntityClazz(),subEntityMetadata,Arrays.asList(rowIds),subEntityMetadata.getRelationNames());
        if (!results.isEmpty()) {
          break;
        }
      }
    }
 else {
      results=handler.readAll(entityMetadata.getSchema(),entityMetadata.getEntityClazz(),entityMetadata,Arrays.asList(rowIds),entityMetadata.getRelationNames());
    }
  }
 catch (  IOException ioex) {
    log.error("String_Node_Str",ioex);
    throw new KunderaException(ioex);
  }
  return results;
}
Program: 176156
Project: 176156
Buggy source:
/** 
 * Handles find by range query for given start and end row key range values.
 * @param < E > parameterized entity class.
 * @param entityClass entity class.
 * @param metadata entity metadata
 * @param startRow start row.
 * @param endRow end row.
 * @return collection holding results.
 */
public <E>List<E> findByRange(Class<E> entityClass,EntityMetadata metadata,byte[] startRow,byte[] endRow,String[] columns,Filter f){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entityClass);
  String tableName=entityMetadata.getSchema();
  List results=new ArrayList();
  FilterList filter=new FilterList();
  if (f != null) {
    filter.addFilter(f);
  }
  if (isFindKeyOnly(metadata,columns)) {
    columns=null;
    filter.addFilter(new KeyOnlyFilter());
  }
  try {
    results=handler.readDataByRange(tableName,entityClass,metadata,startRow,endRow,columns,filter);
  }
 catch (  IOException ioex) {
    log.error("String_Node_Str",ioex);
    throw new KunderaException(ioex);
  }
  return results;
}

Fixed version (ground truth):
/** 
 * Handles find by range query for given start and end row key range values.
 * @param < E > parameterized entity class.
 * @param entityClass entity class.
 * @param metadata entity metadata
 * @param startRow start row.
 * @param endRow end row.
 * @return collection holding results.
 */
public <E>List<E> findByRange(Class<E> entityClass,EntityMetadata metadata,byte[] startRow,byte[] endRow,String[] columns,Filter f){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entityClass);
  String tableName=entityMetadata.getSchema();
  List results=new ArrayList();
  FilterList filter=new FilterList();
  if (f != null) {
    filter.addFilter(f);
  }
  if (isFindKeyOnly(metadata,columns)) {
    columns=null;
    filter.addFilter(new KeyOnlyFilter());
  }
  try {
    MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(entityMetadata.getPersistenceUnit());
    EntityType entityType=metaModel.entity(entityClass);
    List<AbstractManagedType> subManagedType=((AbstractManagedType)entityType).getSubManagedType();
    if (!subManagedType.isEmpty()) {
      for (      AbstractManagedType subEntity : subManagedType) {
        EntityMetadata subEntityMetadata=KunderaMetadataManager.getEntityMetadata(subEntity.getJavaType());
        List found=handler.readDataByRange(tableName,subEntityMetadata.getEntityClazz(),subEntityMetadata,startRow,endRow,columns,filter);
        results.addAll(found);
      }
    }
 else {
      results=handler.readDataByRange(tableName,entityClass,metadata,startRow,endRow,columns,filter);
    }
  }
 catch (  IOException ioex) {
    log.error("String_Node_Str",ioex);
    throw new KunderaException(ioex);
  }
  return results;
}
Program: 176157
Project: 176157
Buggy source:
@Override public List<Object> findByRelation(String colName,Object colValue,Class entityClazz){
  CompareOp operator=HBaseUtils.getOperator("String_Node_Str",false);
  EntityMetadata m=KunderaMetadataManager.getEntityMetadata(entityClazz);
  String columnFamilyName=m.getTableName();
  byte[] valueInBytes=HBaseUtils.getBytes(colValue);
  SingleColumnValueFilter f=null;
  f=new SingleColumnValueFilter(Bytes.toBytes(columnFamilyName),Bytes.toBytes(colName),operator,valueInBytes);
  try {
    return ((HBaseDataHandler)handler).scanData(f,m.getSchema(),entityClazz,m,columnFamilyName,colName);
  }
 catch (  IOException ioe) {
    log.error("String_Node_Str",ioe);
    throw new KunderaException(ioe);
  }
catch (  InstantiationException ie) {
    log.error("String_Node_Str",ie);
    throw new KunderaException(ie);
  }
catch (  IllegalAccessException iae) {
    log.error("String_Node_Str",iae);
    throw new KunderaException(iae);
  }
}

Fixed version (ground truth):
@Override public List<Object> findByRelation(String colName,Object colValue,Class entityClazz){
  CompareOp operator=HBaseUtils.getOperator("String_Node_Str",false);
  EntityMetadata m=KunderaMetadataManager.getEntityMetadata(entityClazz);
  String columnFamilyName=m.getTableName();
  byte[] valueInBytes=HBaseUtils.getBytes(colValue);
  SingleColumnValueFilter f=null;
  f=new SingleColumnValueFilter(Bytes.toBytes(columnFamilyName),Bytes.toBytes(colName),operator,valueInBytes);
  List output=new ArrayList();
  try {
    List<AbstractManagedType> subManagedType=getSubManagedType(entityClazz,m);
    if (!subManagedType.isEmpty()) {
      for (      AbstractManagedType subEntity : subManagedType) {
        EntityMetadata subEntityMetadata=KunderaMetadataManager.getEntityMetadata(subEntity.getJavaType());
        List results=((HBaseDataHandler)handler).scanData(f,subEntityMetadata.getSchema(),subEntityMetadata.getEntityClazz(),subEntityMetadata,columnFamilyName,colName);
        if (!results.isEmpty()) {
          output.addAll(results);
        }
      }
    }
 else {
      return ((HBaseDataHandler)handler).scanData(f,m.getSchema(),entityClazz,m,columnFamilyName,colName);
    }
  }
 catch (  IOException ioe) {
    log.error("String_Node_Str",ioe);
    throw new KunderaException(ioe);
  }
catch (  InstantiationException ie) {
    log.error("String_Node_Str",ie);
    throw new KunderaException(ie);
  }
catch (  IllegalAccessException iae) {
    log.error("String_Node_Str",iae);
    throw new KunderaException(iae);
  }
  return output;
}
Program: 176158
Project: 176158
Buggy source:
/** 
 * (non-Javadoc)
 * @see com.impetus.kundera.client.Client#find(java.lang.Class,java.util.Map)
 */
@Override public <E>List<E> find(Class<E> entityClass,Map<String,String> col){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(getPersistenceUnit(),entityClass);
  List<E> entities=new ArrayList<E>();
  Map<String,Field> columnFamilyNameToFieldMap=MetadataUtils.createSuperColumnsFieldMap(entityMetadata);
  for (  String columnFamilyName : col.keySet()) {
    String entityId=col.get(columnFamilyName);
    if (entityId != null) {
      E e=null;
      try {
        List results=handler.readData(entityMetadata.getSchema(),entityMetadata.getEntityClazz(),entityMetadata,entityId,null,null);
        if (results != null) {
          e=(E)results.get(0);
        }
      }
 catch (      IOException ioex) {
        log.error("String_Node_Str",ioex);
        throw new KunderaException(ioex);
      }
      Field columnFamilyField=columnFamilyNameToFieldMap.get(columnFamilyName.substring(0,columnFamilyName.indexOf("String_Node_Str")));
      Object columnFamilyValue=PropertyAccessorHelper.getObject(e,columnFamilyField);
      if (Collection.class.isAssignableFrom(columnFamilyField.getType())) {
        entities.addAll((Collection)columnFamilyValue);
      }
 else {
        entities.add((E)columnFamilyValue);
      }
    }
  }
  return entities;
}

Fixed version (ground truth):
/** 
 * (non-Javadoc)
 * @see com.impetus.kundera.client.Client#find(java.lang.Class,java.util.Map)
 */
@Override public <E>List<E> find(Class<E> entityClass,Map<String,String> col){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(getPersistenceUnit(),entityClass);
  List<E> entities=new ArrayList<E>();
  Map<String,Field> columnFamilyNameToFieldMap=MetadataUtils.createSuperColumnsFieldMap(entityMetadata);
  for (  String columnFamilyName : col.keySet()) {
    String entityId=col.get(columnFamilyName);
    if (entityId != null) {
      E e=null;
      try {
        List results=new ArrayList();
        fetchEntity(entityClass,entityId,entityMetadata,entityMetadata.getRelationNames(),entityMetadata.getSchema(),results,null,null);
        if (results != null) {
          e=(E)results.get(0);
        }
      }
 catch (      IOException ioex) {
        log.error("String_Node_Str",ioex);
        throw new KunderaException(ioex);
      }
      Field columnFamilyField=columnFamilyNameToFieldMap.get(columnFamilyName.substring(0,columnFamilyName.indexOf("String_Node_Str")));
      Object columnFamilyValue=PropertyAccessorHelper.getObject(e,columnFamilyField);
      if (Collection.class.isAssignableFrom(columnFamilyField.getType())) {
        entities.addAll((Collection)columnFamilyValue);
      }
 else {
        entities.add((E)columnFamilyValue);
      }
    }
  }
  return entities;
}
Program: 176159
Project: 176159
Buggy source:
/** 
 * Method to find entities using JPQL(converted into FilterList.)
 * @param < E > parameterized entity class.
 * @param entityClass entity class.
 * @param metadata entity metadata.
 * @return list of entities.
 */
public <E>List<E> findByQuery(Class<E> entityClass,EntityMetadata metadata,Filter f,String... columns){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entityClass);
  List<String> relationNames=entityMetadata.getRelationNames();
  String tableName=entityMetadata.getSchema();
  List results=null;
  FilterList filter=new FilterList();
  if (f != null) {
    filter.addFilter(f);
  }
  if (isFindKeyOnly(metadata,columns)) {
    columns=null;
    filter.addFilter(new KeyOnlyFilter());
  }
  try {
    results=handler.readData(tableName,entityMetadata.getEntityClazz(),entityMetadata,null,relationNames,filter,columns);
  }
 catch (  IOException ioex) {
    log.error("String_Node_Str",ioex);
    throw new KunderaException(ioex);
  }
  return results != null ? results : new ArrayList();
}

Fixed version (ground truth):
/** 
 * Method to find entities using JPQL(converted into FilterList.)
 * @param < E > parameterized entity class.
 * @param entityClass entity class.
 * @param metadata entity metadata.
 * @return list of entities.
 */
public <E>List<E> findByQuery(Class<E> entityClass,EntityMetadata metadata,Filter f,String... columns){
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(entityClass);
  List<String> relationNames=entityMetadata.getRelationNames();
  String tableName=entityMetadata.getSchema();
  List results=null;
  FilterList filter=new FilterList();
  if (f != null) {
    filter.addFilter(f);
  }
  if (isFindKeyOnly(metadata,columns)) {
    columns=null;
    filter.addFilter(new KeyOnlyFilter());
  }
  try {
    results=fetchEntity(entityClass,null,entityMetadata,relationNames,tableName,results,filter,columns);
  }
 catch (  IOException ioex) {
    log.error("String_Node_Str",ioex);
    throw new KunderaException(ioex);
  }
  return results != null ? results : new ArrayList();
}
Program: 176160
Project: 176160
Buggy source:
/** 
 * Sets the columns.
 * @param columns the new columns
 */
public void setColumns(List<KeyValue> columns){
  this.columns=columns;
}

Fixed version (ground truth):
public void setColumns(List<KeyValue> columns){
  for (  KeyValue column : columns) {
    putColumn(column.getQualifier(),column.getValue());
  }
}
Program: 176161
Project: 176161
Buggy source:
/** 
 * Getter for list of columns.
 * @return list of columns
 */
public List<KeyValue> getColumns(){
  return columns != null ? Collections.unmodifiableList(columns) : null;
}

Fixed version (ground truth):
public Map<String,byte[]> getColumns(){
  return columns;
}
Program: 176162
Project: 176162
Buggy source:
private void assertRelation(EntityManager em){
  List<SocialProfile> profiles=new ArrayList<SocialProfile>();
  FacebookProfile fbprofile=new FacebookProfile();
  fbprofile.setId(103l);
  fbprofile.setFacebookId("String_Node_Str");
  fbprofile.setFacebookUser("String_Node_Str");
  fbprofile.setuserType("String_Node_Str");
  profiles.add(fbprofile);
  TwitterProfile twprofile1=new TwitterProfile();
  twprofile1.setTwitterId("String_Node_Str");
  twprofile1.setTwitterName("String_Node_Str");
  twprofile1.setId(102l);
  profiles.add(twprofile1);
  twprofile1.setuserType("String_Node_Str");
  UserAccount uacc=new UserAccount();
  uacc.setId(101l);
  uacc.setDispName("String_Node_Str");
  uacc.setSocialProfiles(profiles);
  twprofile1.setuserAccount(uacc);
  fbprofile.setuserAccount(uacc);
  em.getTransaction().begin();
  em.persist(uacc);
  em.getTransaction().commit();
  em.clear();
  String uaQuery="String_Node_Str";
  Query q=em.createQuery(uaQuery);
  List<UserAccount> results=q.getResultList();
  Assert.assertEquals(1,results.size());
  Assert.assertEquals("String_Node_Str",results.get(0).getDispName());
  Assert.assertEquals(2,results.get(0).getSocialProfiles().size());
  Assert.assertFalse(results.get(0).getSocialProfiles().get(0).getId().equals(results.get(0).getId()));
  em.clear();
}

Fixed version (ground truth):
private void assertRelation(EntityManager em){
  List<SocialProfile> profiles=new ArrayList<SocialProfile>();
  FacebookProfile fbprofile=new FacebookProfile();
  fbprofile.setId(103l);
  fbprofile.setFacebookId("String_Node_Str");
  fbprofile.setFacebookUser("String_Node_Str");
  fbprofile.setuserType("String_Node_Str");
  profiles.add(fbprofile);
  TwitterProfile twprofile1=new TwitterProfile();
  twprofile1.setTwitterId("String_Node_Str");
  twprofile1.setTwitterName("String_Node_Str");
  twprofile1.setId(102l);
  profiles.add(twprofile1);
  twprofile1.setuserType("String_Node_Str");
  UserAccount uacc=new UserAccount();
  uacc.setId(101l);
  uacc.setDispName("String_Node_Str");
  uacc.setSocialProfiles(profiles);
  twprofile1.setuserAccount(uacc);
  fbprofile.setuserAccount(uacc);
  em.getTransaction().begin();
  em.persist(uacc);
  em.getTransaction().commit();
  em.persist(fbprofile);
  em.persist(twprofile1);
  em.clear();
  String uaQuery="String_Node_Str";
  Query q=em.createQuery(uaQuery);
  List<UserAccount> results=q.getResultList();
  Assert.assertEquals(1,results.size());
  Assert.assertEquals("String_Node_Str",results.get(0).getDispName());
  Assert.assertEquals(2,results.get(0).getSocialProfiles().size());
  Assert.assertFalse(results.get(0).getSocialProfiles().get(0).getId().equals(results.get(0).getId()));
  em.clear();
}
Program: 176163
Project: 176163
Buggy source:
@Override public void handlePersist(NodeStateContext nodeStateContext){
  recursivelyPerformOperation(nodeStateContext,OPERATION.PERSIST);
}

Fixed version (ground truth):
@Override public void handlePersist(NodeStateContext nodeStateContext){
  if (((Node)nodeStateContext).isDirty()) {
    recursivelyPerformOperation(nodeStateContext,OPERATION.PERSIST);
  }
}
Program: 176164
Project: 176164
Buggy source:
/** 
 * Writes an entity into Persistence cache. (Actual database write is done while flushing)
 */
public void persist(Object e){
  if (e == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  EntityMetadata metadata=getMetadata(e.getClass());
  ObjectGraph graph=graphBuilder.getObjectGraph(e,new TransientState());
  Node node=graph.getHeadNode();
  try {
    lock.writeLock().lock();
    node.persist();
    flushManager.buildFlushStack(node,com.impetus.kundera.persistence.context.EventLog.EventType.INSERT);
    flush();
    getPersistenceCache().getMainCache().addHeadNode(node);
  }
  finally {
    lock.writeLock().unlock();
  }
  graph.clear();
  graph=null;
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + e.getClass());
  }
}

Fixed version (ground truth):
/** 
 * Writes an entity into Persistence cache. (Actual database write is done while flushing)
 */
public void persist(Object e){
  if (e == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  ObjectGraph graph=graphBuilder.getObjectGraph(e,new TransientState());
  Node node=graph.getHeadNode();
  try {
    lock.writeLock().lock();
    node.persist();
    flushManager.buildFlushStack(node,com.impetus.kundera.persistence.context.EventLog.EventType.INSERT);
    flush();
    getPersistenceCache().getMainCache().addHeadNode(node);
  }
  finally {
    lock.writeLock().unlock();
  }
  graph.clear();
  graph=null;
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + e.getClass());
  }
}
Program: 176165
Project: 176165
Buggy source:
/** 
 * Method to handle
 * @param node
 */
public void persist(Node node){
  Object entity=node.getData();
  Object id=node.getEntityId();
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(node.getDataClass());
  isUpdate=node.isUpdate();
  List<RelationHolder> relationHolders=getRelationHolders(node);
  onPersist(metadata,entity,id,relationHolders);
  indexNode(node,metadata);
}

Fixed version (ground truth):
/** 
 * Method to handle
 * @param node
 */
public void persist(Node node){
  Object entity=node.getData();
  Object id=node.getEntityId();
  EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(node.getDataClass());
  isUpdate=node.isUpdate();
  List<RelationHolder> relationHolders=getRelationHolders(node);
  onPersist(metadata,entity,id,relationHolders);
  id=PropertyAccessorHelper.getId(entity,metadata);
  node.setEntityId(id);
  indexNode(node,metadata);
}
Program: 176167
Project: 176167
Buggy source:
@Test public void testRelationViaPelops(){
  EntityManagerFactory emfPelops=Persistence.createEntityManagerFactory("String_Node_Str");
  EntityManager emPelops=emfPelops.createEntityManager();
  assertRelation(emPelops);
  emPelops.clear();
  emPelops.close();
  emfPelops.close();
}

Fixed version (ground truth):
public void testRelationViaPelops(){
  EntityManagerFactory emfPelops=Persistence.createEntityManagerFactory("String_Node_Str");
  EntityManager emPelops=emfPelops.createEntityManager();
  assertRelation(emPelops);
  emPelops.clear();
  emPelops.close();
  emfPelops.close();
}
Program: 176168
Project: 176168
Buggy source:
@Test public void testAbstractEntityViaPelops(){
  EntityManagerFactory emfPelops=Persistence.createEntityManagerFactory("String_Node_Str");
  EntityManager emPelops=emfPelops.createEntityManager();
  assertAbstractEntity(emPelops);
  emPelops.clear();
  emPelops.close();
  emfPelops.close();
}

Fixed version (ground truth):
public void testAbstractEntityViaPelops(){
  EntityManagerFactory emfPelops=Persistence.createEntityManagerFactory("String_Node_Str");
  EntityManager emPelops=emfPelops.createEntityManager();
  assertAbstractEntity(emPelops);
  emPelops.clear();
  emPelops.close();
  emfPelops.close();
}
Program: 176169
Project: 176169
Buggy source:
@Before public void setUp() throws Exception {
  ImmutableSettings.Builder builder=ImmutableSettings.settingsBuilder();
  builder.put("String_Node_Str","String_Node_Str");
  node=new NodeBuilder().settings(builder).node();
  _PU="String_Node_Str";
  setUpInternal();
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  if (!checkIfServerRunning()) {
    ImmutableSettings.Builder builder=ImmutableSettings.settingsBuilder();
    builder.put("String_Node_Str","String_Node_Str");
    node=new NodeBuilder().settings(builder).node();
  }
  _PU="String_Node_Str";
  setUpInternal();
}
Program: 176170
Project: 176170
Buggy source:
@After public void tearDown() throws Exception {
  node.close();
  tearDownInternal();
  KunderaMetadata.INSTANCE.setApplicationMetadata(null);
}

Fixed version (ground truth):
@After public void tearDown() throws Exception {
  if (checkIfServerRunning()) {
    node.close();
  }
  tearDownInternal();
  KunderaMetadata.INSTANCE.setApplicationMetadata(null);
}
Program: 176172
Project: 176172
Buggy source:
@BeforeClass public static void setUpBeforeClass() throws Exception {
  ImmutableSettings.Builder builder=ImmutableSettings.settingsBuilder();
  builder.put("String_Node_Str","String_Node_Str");
  node=new NodeBuilder().settings(builder).node();
}

Fixed version (ground truth):
@BeforeClass public static void setUpBeforeClass() throws Exception {
  if (!checkIfServerRunning()) {
    ImmutableSettings.Builder builder=ImmutableSettings.settingsBuilder();
    builder.put("String_Node_Str","String_Node_Str");
    node=new NodeBuilder().settings(builder).node();
  }
}
Program: 176173
Project: 176173
Buggy source:
@AfterClass public static void tearDownAfterClass() throws Exception {
  node.close();
  KunderaMetadata.INSTANCE.setApplicationMetadata(null);
}

Fixed version (ground truth):
@AfterClass public static void tearDownAfterClass() throws Exception {
  if (checkIfServerRunning()) {
    node.close();
  }
  KunderaMetadata.INSTANCE.setApplicationMetadata(null);
}
Program: 176174
Project: 176174
Buggy source:
/** 
 * If parameterised metadata is not for intended persistence unit, assign it to null.
 * @param metadata entity metadata
 * @return metadata.
 */
private EntityMetadata belongsToPersistenceUnit(EntityMetadata metadata){
  PersistenceUnitMetadata puMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata().getPersistenceUnitMetadata(persistenceUnit);
  String keyspace=puProperties != null ? (String)puProperties.get(PersistenceProperties.KUNDERA_KEYSPACE) : null;
  keyspace=keyspace == null ? puMetadata.getProperty(PersistenceProperties.KUNDERA_KEYSPACE) : keyspace;
  if (metadata.getPersistenceUnit() != null && !metadata.getPersistenceUnit().equals(persistenceUnit) || (metadata.getSchema() != null && !metadata.getSchema().equals(keyspace))) {
    metadata=null;
  }
 else {
    applyMetadataChanges(metadata);
  }
  return metadata;
}

Fixed version (ground truth):
/** 
 * If parameterised metadata is not for intended persistence unit, assign it to null.
 * @param metadata entity metadata
 * @return metadata.
 */
private EntityMetadata belongsToPersistenceUnit(EntityMetadata metadata){
  PersistenceUnitMetadata puMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata().getPersistenceUnitMetadata(persistenceUnit);
  String keyspace=puProperties != null ? (String)puProperties.get(PersistenceProperties.KUNDERA_KEYSPACE) : null;
  keyspace=keyspace == null ? puMetadata.getProperty(PersistenceProperties.KUNDERA_KEYSPACE) : keyspace;
  if (metadata.getPersistenceUnit() != null && !metadata.getPersistenceUnit().equals(persistenceUnit) || (keyspace != null && metadata.getSchema() != null && !metadata.getSchema().equals(keyspace))) {
    metadata=null;
  }
 else {
    applyMetadataChanges(metadata);
  }
  return metadata;
}
Program: 176175
Project: 176175
Buggy source:
@Override protected Object createPoolOrConnection(){
  getConfigurationObject();
  Collection<Class<?>> classes=((MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(getPersistenceUnit())).getEntityNameToClassMap().values();
  conf.setProperty("String_Node_Str","String_Node_Str");
  if (externalProperties != null && !externalProperties.isEmpty()) {
    for (    String key : externalProperties.keySet()) {
      Object value=externalProperties.get(key);
      if (value instanceof String) {
        conf.setProperty(key,(String)value);
      }
    }
  }
  serviceRegistry=new ServiceRegistryBuilder().applySettings(conf.getProperties()).buildServiceRegistry();
  for (  Class<?> c : classes) {
    conf.addAnnotatedClass(c);
  }
  sf=conf.buildSessionFactory(serviceRegistry);
  return sf;
}

Fixed version (ground truth):
@Override protected Object createPoolOrConnection(){
  getConfigurationObject();
  Set<String> pus=KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodelMap().keySet();
  Collection<Class<?>> classes=new ArrayList<Class<?>>();
  for (  String pu : pus) {
    classes.addAll(((MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(pu)).getEntityNameToClassMap().values());
  }
  conf.setProperty("String_Node_Str","String_Node_Str");
  if (externalProperties != null && !externalProperties.isEmpty()) {
    for (    String key : externalProperties.keySet()) {
      Object value=externalProperties.get(key);
      if (value instanceof String) {
        conf.setProperty(key,(String)value);
      }
    }
  }
  serviceRegistry=new ServiceRegistryBuilder().applySettings(conf.getProperties()).buildServiceRegistry();
  for (  Class<?> c : classes) {
    conf.addAnnotatedClass(c);
  }
  sf=conf.buildSessionFactory(serviceRegistry);
  return sf;
}
Program: 176176
Project: 176176
Buggy source:
/** 
 * Returns default index reader.
 * @return index reader.
 */
private IndexReader getIndexReader(){
  flushInternal();
  if (reader == null) {
    try {
      if (!isInitialized) {
        Directory sourceDir=FSDirectory.open(getIndexDirectory());
        copy(sourceDir,index);
        isInitialized=true;
      }
      reader=IndexReader.open(index);
    }
 catch (    Exception e) {
      log.error("String_Node_Str",e);
      throw new LuceneIndexingException(e);
    }
  }
  return reader;
}

Fixed version (ground truth):
/** 
 * Returns default index reader.
 * @return index reader.
 */
private IndexReader getIndexReader(){
  flushInternal();
  if (reader == null) {
    try {
      if (!isInitialized) {
        Directory sourceDir=FSDirectory.open(getIndexDirectory());
        copy(sourceDir,index);
        isInitialized=true;
      }
      reader=IndexReader.open(index);
    }
 catch (    IndexNotFoundException infex) {
      log.warn("String_Node_Str",infex.getMessage());
    }
catch (    Exception e) {
      log.error("String_Node_Str",e);
      throw new LuceneIndexingException(e);
    }
  }
  return reader;
}
Program: 176177
Project: 176177
Buggy source:
public static boolean indexSearchEnabled(final String persistenceUnit){
  PersistenceUnitMetadata puMetadata=KunderaMetadataManager.getPersistenceUnitMetadata(persistenceUnit);
  String clientFactoryName=puMetadata != null ? puMetadata.getProperty(PersistenceProperties.KUNDERA_CLIENT_FACTORY) : null;
  return !(Constants.REDIS_CLIENT_FACTORY.equalsIgnoreCase(clientFactoryName));
}

Fixed version (ground truth):
/** 
 * Index based search has to be optional, ideally need to register a callback in case index persistence/search etc is optional.
 * @param persistenceUnit persistence unit
 * @return true, if index based search is enabled.
 */
public static boolean indexSearchEnabled(final String persistenceUnit){
  PersistenceUnitMetadata puMetadata=KunderaMetadataManager.getPersistenceUnitMetadata(persistenceUnit);
  String clientFactoryName=puMetadata != null ? puMetadata.getProperty(PersistenceProperties.KUNDERA_CLIENT_FACTORY) : null;
  return !(Constants.REDIS_CLIENT_FACTORY.equalsIgnoreCase(clientFactoryName));
}
Program: 176182
Project: 176182
Buggy source:
/** 
 * @throws java.lang.Exception
 */
@After public void tearDown() throws Exception {
  EntityManager em=emf.createEntityManager();
  String deleteQuery="String_Node_Str";
  Query query=em.createQuery(deleteQuery);
  int updateCount=query.executeUpdate();
  em.close();
  emf.close();
  emf=null;
}

Fixed version (ground truth):
/** 
 * @throws java.lang.Exception
 */
@After public void tearDown() throws Exception {
  EntityManager em=emf.createEntityManager();
  purge(em);
  em.close();
  emf.close();
  emf=null;
}
Program: 176183
Project: 176183
Buggy source:
public static void main(String[] args){
  Runnable t=new Runnable(){
    @Override public void run(){
      KunderaRedisClient cli=new KunderaRedisClient();
      Properties props=new Properties();
      props.setProperty("String_Node_Str","String_Node_Str");
      cli.setProperties(props);
      try {
        cli.init();
      }
 catch (      Exception e) {
        logger.error(e);
        System.exit(0);
      }
      HashMap<String,ByteIterator> vals=new HashMap<String,ByteIterator>();
      vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
      vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
      vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
      cli.read("String_Node_Str","String_Node_Str",null,null);
      try {
        cli.cleanup();
      }
 catch (      DBException e) {
        e.printStackTrace();
      }
    }
  }
;
  for (int i=0; i < 100; i++) {
    t.run();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  Runnable t=new Runnable(){
    @Override public void run(){
      KunderaRedisClient cli=new KunderaRedisClient();
      Properties props=new Properties();
      props.setProperty("String_Node_Str","String_Node_Str");
      cli.setProperties(props);
      try {
        cli.init();
      }
 catch (      Exception e) {
        logger.error(e);
        System.exit(0);
      }
      HashMap<String,ByteIterator> vals=new HashMap<String,ByteIterator>();
      vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
      vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
      vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
      int res=cli.insert("String_Node_Str","String_Node_Str",vals);
      cli.read("String_Node_Str","String_Node_Str",null,null);
      System.out.println("String_Node_Str" + res);
      try {
        cli.cleanup();
      }
 catch (      DBException e) {
        e.printStackTrace();
      }
    }
  }
;
  for (int i=0; i < 100; i++) {
    t.run();
  }
}
Program: 176184
Project: 176184
Buggy source:
@Override public void run(){
  KunderaRedisClient cli=new KunderaRedisClient();
  Properties props=new Properties();
  props.setProperty("String_Node_Str","String_Node_Str");
  cli.setProperties(props);
  try {
    cli.init();
  }
 catch (  Exception e) {
    logger.error(e);
    System.exit(0);
  }
  HashMap<String,ByteIterator> vals=new HashMap<String,ByteIterator>();
  vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
  vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
  vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
  cli.read("String_Node_Str","String_Node_Str",null,null);
  try {
    cli.cleanup();
  }
 catch (  DBException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void run(){
  KunderaRedisClient cli=new KunderaRedisClient();
  Properties props=new Properties();
  props.setProperty("String_Node_Str","String_Node_Str");
  cli.setProperties(props);
  try {
    cli.init();
  }
 catch (  Exception e) {
    logger.error(e);
    System.exit(0);
  }
  HashMap<String,ByteIterator> vals=new HashMap<String,ByteIterator>();
  vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
  vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
  vals.put("String_Node_Str",new StringByteIterator("String_Node_Str"));
  int res=cli.insert("String_Node_Str","String_Node_Str",vals);
  cli.read("String_Node_Str","String_Node_Str",null,null);
  System.out.println("String_Node_Str" + res);
  try {
    cli.cleanup();
  }
 catch (  DBException e) {
    e.printStackTrace();
  }
}
Program: 176185
Project: 176185
Buggy source:
/** 
 * Insert a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified record key.
 * @param table The name of the table
 * @param key The record key of the record to insert.
 * @param values A HashMap of field/value pairs to insert in the record
 * @return Zero on success, a non-zero error code on error
 */
public int insert(String table,String key,HashMap<String,ByteIterator> values){
  try {
    if (_hTable == null) {
      getHTable(_table);
    }
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str" + e);
    return ServerError;
  }
  if (_debug) {
    System.out.println("String_Node_Str" + key);
  }
  Put p=new Put(Bytes.toBytes(key));
  for (  Map.Entry<String,ByteIterator> entry : values.entrySet()) {
    if (_debug) {
      System.out.println("String_Node_Str" + entry.getKey() + "String_Node_Str"+ entry.getValue()+ "String_Node_Str");
    }
    p.add(_columnFamilyBytes,Bytes.toBytes(entry.getKey()),entry.getValue().toArray());
  }
  try {
    _hTable.put(p);
  }
 catch (  IOException e) {
    if (_debug) {
      System.err.println("String_Node_Str" + e);
    }
    return ServerError;
  }
catch (  ConcurrentModificationException e) {
    return ServerError;
  }
  return Ok;
}

Fixed version (ground truth):
/** 
 * Insert a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified record key.
 * @param table The name of the table
 * @param key The record key of the record to insert.
 * @param values A HashMap of field/value pairs to insert in the record
 * @return Zero on success, a non-zero error code on error
 */
public int insert(String table,String key,HashMap<String,ByteIterator> values){
  try {
    getHTable(_table);
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str" + e);
    return ServerError;
  }
  if (_debug) {
    System.out.println("String_Node_Str" + key);
  }
  Put p=new Put(Bytes.toBytes(key));
  for (  Map.Entry<String,ByteIterator> entry : values.entrySet()) {
    if (_debug) {
      System.out.println("String_Node_Str" + entry.getKey() + "String_Node_Str"+ entry.getValue()+ "String_Node_Str");
    }
    p.add(_columnFamilyBytes,Bytes.toBytes(entry.getKey()),entry.getValue().toArray());
  }
  try {
    _hTable.put(p);
  }
 catch (  IOException e) {
    if (_debug) {
      System.err.println("String_Node_Str" + e);
    }
    return ServerError;
  }
catch (  ConcurrentModificationException e) {
    return ServerError;
  }
  return Ok;
}
Program: 176186
Project: 176186
Buggy source:
/** 
 * Based on relation type, method invokes database to fetch relation entities.
 * @param relation relation
 * @param metadata entity metadata
 * @param pd persistence delegator
 * @param entityId entity id
 * @param relationValue relational value
 * @param targetEntityMetadata relational entity's metadata.
 * @return list of fetched relations.
 */
private List fetchRelations(final Relation relation,final EntityMetadata metadata,final PersistenceDelegator pd,final Object entityId,Object relationValue,EntityMetadata targetEntityMetadata){
  List relationalEntities=new ArrayList();
  if ((relationValue != null && relation.isUnary()) || (relation.isJoinedByPrimaryKey())) {
    Object relationEntity=pd.getClient(targetEntityMetadata).find(relation.getTargetEntity(),relationValue != null ? relationValue : entityId);
    if (relationEntity != null) {
      relationalEntities.add(relationEntity);
    }
  }
 else   if (!relation.isUnary()) {
    Client associatedClient=pd.getClient(targetEntityMetadata);
    if (!MetadataUtils.useSecondryIndex(((ClientBase)associatedClient).getClientMetadata())) {
      relationalEntities=getAssociationBuilder().getAssociatedEntitiesFromIndex(relation.getProperty().getDeclaringClass(),entityId,targetEntityMetadata.getEntityClazz(),associatedClient);
    }
 else {
      relationalEntities=associatedClient.findByRelation(relation.getJoinColumnName(),entityId,relation.getTargetEntity());
    }
  }
  return relationalEntities;
}

Fixed version (ground truth):
/** 
 * Based on relation type, method invokes database to fetch relation entities.
 * @param relation relation
 * @param metadata entity metadata
 * @param pd persistence delegator
 * @param entityId entity id
 * @param relationValue relational value
 * @param targetEntityMetadata relational entity's metadata.
 * @return list of fetched relations.
 */
private List fetchRelations(final Relation relation,final EntityMetadata metadata,final PersistenceDelegator pd,final Object entityId,Object relationValue,EntityMetadata targetEntityMetadata){
  List relationalEntities=new ArrayList();
  if ((relationValue != null && relation.isUnary()) || (relation.isJoinedByPrimaryKey())) {
    Object relationEntity=pd.getClient(targetEntityMetadata).find(relation.getTargetEntity(),relationValue != null ? relationValue : entityId);
    if (relationEntity != null) {
      relationalEntities.add(relationEntity);
    }
  }
 else   if (!relation.isUnary()) {
    Client associatedClient=pd.getClient(targetEntityMetadata);
    if (!MetadataUtils.useSecondryIndex(((ClientBase)associatedClient).getClientMetadata()) && MetadataUtils.indexSearchEnabled(targetEntityMetadata.getPersistenceUnit())) {
      relationalEntities=getAssociationBuilder().getAssociatedEntitiesFromIndex(relation.getProperty().getDeclaringClass(),entityId,targetEntityMetadata.getEntityClazz(),associatedClient);
    }
 else {
      relationalEntities=associatedClient.findByRelation(relation.getJoinColumnName(),entityId,relation.getTargetEntity());
    }
  }
  return relationalEntities;
}
Program: 176188
Project: 176188
Buggy source:
/** 
 * Wraps entity attributes into redis format byte[]
 * @param entityMetadata
 * @param wrapper
 * @param embeddedObject
 * @param attrib
 * @param embeddedAttrib
 */
private void addToWrapper(EntityMetadata entityMetadata,AttributeWrapper wrapper,Object embeddedObject,Attribute attrib,Attribute embeddedAttrib){
  byte[] value=PropertyAccessorHelper.get(embeddedObject,(Field)attrib.getJavaMember());
  String valueAsStr=PropertyAccessorHelper.getString(embeddedObject,(Field)attrib.getJavaMember());
  byte[] name;
  if (value != null) {
    if (embeddedAttrib == null) {
      name=getEncodedBytes(((AbstractAttribute)attrib).getJPAColumnName());
    }
 else {
      name=getEncodedBytes(getHashKey(embeddedAttrib.getName(),((AbstractAttribute)attrib).getJPAColumnName()));
    }
    wrapper.addColumn(name,value);
    wrapper.addIndex(getHashKey(entityMetadata.getTableName(),((AbstractAttribute)attrib).getJPAColumnName()),getDouble(valueAsStr));
    wrapper.addIndex(getHashKey(entityMetadata.getTableName(),getHashKey(((AbstractAttribute)attrib).getJPAColumnName(),valueAsStr)),getDouble(valueAsStr));
  }
}

Fixed version (ground truth):
/** 
 * Wraps entity attributes into redis format byte[]
 * @param entityMetadata
 * @param wrapper
 * @param embeddedObject
 * @param attrib
 * @param embeddedAttrib
 */
private void addToWrapper(EntityMetadata entityMetadata,AttributeWrapper wrapper,Object embeddedObject,Attribute attrib,Attribute embeddedAttrib){
  byte[] value=PropertyAccessorHelper.get(embeddedObject,(Field)attrib.getJavaMember());
  String valueAsStr=PropertyAccessorHelper.getString(embeddedObject,(Field)attrib.getJavaMember());
  byte[] name;
  if (value != null) {
    if (embeddedAttrib == null) {
      name=getEncodedBytes(((AbstractAttribute)attrib).getJPAColumnName());
    }
 else {
      name=getEncodedBytes(getHashKey(embeddedAttrib.getName(),((AbstractAttribute)attrib).getJPAColumnName()));
    }
    wrapper.addColumn(name,value);
    if (entityMetadata.getIndexProperties().containsKey(((AbstractAttribute)attrib).getJPAColumnName())) {
      wrapper.addIndex(getHashKey(entityMetadata.getTableName(),((AbstractAttribute)attrib).getJPAColumnName()),getDouble(valueAsStr));
      wrapper.addIndex(getHashKey(entityMetadata.getTableName(),getHashKey(((AbstractAttribute)attrib).getJPAColumnName(),valueAsStr)),getDouble(valueAsStr));
    }
  }
}
Program: 176189
Project: 176189
Buggy source:
Map<String,Double> getIndexes(){
  return indexes;
}

Fixed version (ground truth):
Map getIndexes(){
  return indexes;
}
Program: 176190
Project: 176190
Buggy source:
/** 
 * Add inverted index in sorted set.
 * @param connection redis connection instance
 * @param wrapper attribute wrapper.
 * @param rowKey row key to be stor
 */
private void addIndex(final Object connection,final AttributeWrapper wrapper,final String rowKey){
  Set<String> indexKeys=wrapper.getIndexes().keySet();
  for (  String idx_Name : indexKeys) {
    if (resource != null && resource.isActive()) {
      ((Transaction)connection).zadd(idx_Name,wrapper.getIndexes().get(idx_Name),rowKey);
    }
 else {
      ((Pipeline)connection).zadd(idx_Name,wrapper.getIndexes().get(idx_Name),rowKey);
    }
  }
}

Fixed version (ground truth):
/** 
 * Add inverted index in sorted set.
 * @param connection redis connection instance
 * @param wrapper attribute wrapper.
 * @param rowKey row key to be stor
 */
private void addIndex(final Object connection,final AttributeWrapper wrapper,final String rowKey,final EntityMetadata metadata){
  Indexer indexer=indexManager.getIndexer();
  if (indexer != null) {
    indexer.index(metadata.getEntityClazz(),wrapper.getIndexes(),rowKey,null);
  }
}
Program: 176191
Project: 176191
Buggy source:
RedisClient(final RedisClientFactory factory,final String persistenceUnit){
  this.factory=factory;
  reader=new RedisEntityReader();
  this.indexManager=factory.getIndexManager();
  this.persistenceUnit=persistenceUnit;
  this.clientMetadata=factory.getClientMetadata();
  setBatchSize(persistenceUnit,factory.getOverridenProperties());
}

Fixed version (ground truth):
RedisClient(final RedisClientFactory factory,final String persistenceUnit){
  this.factory=factory;
  reader=new RedisEntityReader();
  this.indexManager=factory.getIndexManager();
  initializeIndexer();
  this.persistenceUnit=persistenceUnit;
  this.clientMetadata=factory.getClientMetadata();
  setBatchSize(persistenceUnit,factory.getOverridenProperties());
}
Program: 176193
Project: 176193
Buggy source:
/** 
 */
public void clear(){
  this.nodeMappings.clear();
  this.headNodes.clear();
  this.nodeMappings=null;
  this.headNodes=null;
  nodeMappings=new HashMap<String,Node>();
  headNodes=new HashSet<Node>();
}

Fixed version (ground truth):
/** 
 */
public void clear(){
  if (this.nodeMappings != null) {
    this.nodeMappings.clear();
  }
  if (this.headNodes != null) {
    this.headNodes.clear();
  }
}
Program: 176194
Project: 176194
Buggy source:
/** 
 * Empties Flush stack present in a PersistenceCache.
 */
public void clearFlushStack(){
  if (stackQueue != null && !stackQueue.isEmpty()) {
    stackQueue.clear();
  }
  if (joinTableDataCollection != null && !joinTableDataCollection.isEmpty()) {
    joinTableDataCollection.clear();
    joinTableDataCollection=null;
    joinTableDataCollection=new ArrayList<JoinTableData>();
  }
  if (eventLogQueue != null) {
    eventLogQueue.clear();
  }
}

Fixed version (ground truth):
/** 
 * Empties Flush stack present in a PersistenceCache.
 */
public void clearFlushStack(){
  if (stackQueue != null && !stackQueue.isEmpty()) {
    stackQueue.clear();
  }
  if (joinTableDataCollection != null && !joinTableDataCollection.isEmpty()) {
    joinTableDataCollection.clear();
  }
  if (eventLogQueue != null) {
    eventLogQueue.clear();
  }
}
Program: 176195
Project: 176195
Buggy source:
/** 
 * Cleaned out the data.
 */
public void clean(){
  if (mainCache != null) {
    mainCache.clear();
    mainCache=null;
  }
  if (embeddedCache != null) {
    embeddedCache.clear();
    embeddedCache=null;
  }
  if (elementCollectionCache != null) {
    elementCollectionCache.clear();
    elementCollectionCache=null;
  }
  if (transactionalCache != null) {
    transactionalCache.clear();
    transactionalCache=null;
  }
  initialize();
}

Fixed version (ground truth):
/** 
 * Cleaned out the data.
 */
public void clean(){
  if (mainCache != null) {
    mainCache.clear();
  }
  if (embeddedCache != null) {
    embeddedCache.clear();
  }
  if (elementCollectionCache != null) {
    elementCollectionCache.clear();
  }
  if (transactionalCache != null) {
    transactionalCache.clear();
  }
}