nus-yam/ex-repair huggingface dataset:
Program: 177041
Project: 177041
Buggy source:
public void setPerson(Person person){
  this.person=person;
}

Fixed version (ground truth):
public void setPerson(Person2 person){
  this.person=person;
}
Program: 177042
Project: 177042
Buggy source:
@Override public void unload(String... persistenceUnits){
  indexManager.close();
  Pelops.shutdown();
}

Fixed version (ground truth):
@Override public void unload(String... persistenceUnits){
  indexManager.close();
  Pelops.removePool(poolName);
  Pelops.shutdown();
}
Program: 177043
Project: 177043
Buggy source:
@Override protected Object createPoolOrConnection(){
  PersistenceUnitMetadata persistenceUnitMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata().getPersistenceUnitMetadata(getPersistenceUnit());
  Properties props=persistenceUnitMetadata.getProperties();
  String contactNodes=(String)props.get("String_Node_Str");
  String defaultPort=(String)props.get("String_Node_Str");
  String keyspace=(String)props.get("String_Node_Str");
  String poolName=PelopsUtils.generatePoolName(getPersistenceUnit());
  if (Pelops.getDbConnPool(poolName) == null) {
    Cluster cluster=new Cluster(contactNodes,new IConnection.Config(Integer.parseInt(defaultPort),true,-1),false);
    Pelops.addPool(poolName,cluster,keyspace);
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object createPoolOrConnection(){
  PersistenceUnitMetadata persistenceUnitMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata().getPersistenceUnitMetadata(getPersistenceUnit());
  Properties props=persistenceUnitMetadata.getProperties();
  String contactNodes=(String)props.get("String_Node_Str");
  String defaultPort=(String)props.get("String_Node_Str");
  String keyspace=(String)props.get("String_Node_Str");
  poolName=PelopsUtils.generatePoolName(getPersistenceUnit());
  if (Pelops.getDbConnPool(poolName) == null) {
    Cluster cluster=new Cluster(contactNodes,new IConnection.Config(Integer.parseInt(defaultPort),true,-1),false);
    Pelops.addPool(poolName,cluster,keyspace);
  }
  return null;
}
Program: 177044
Project: 177044
Buggy source:
/** 
 * One time initialization at Application and Client level
 * @param persistenceUnit Persistence Unit/ Comma separated persistence units
 */
private void initializeKundera(String persistenceUnit){
  logger.info("String_Node_Str" + persistenceUnit);
  String[] persistenceUnits=persistenceUnit.split(Constants.PERSISTENCE_UNIT_SEPARATOR);
  (new ApplicationLoader()).load(persistenceUnits);
  logger.info("String_Node_Str" + persistenceUnit);
  for (  String pu : persistenceUnits) {
    ClientResolver.getClientFactory(pu).load(pu);
  }
}

Fixed version (ground truth):
/** 
 * One time initialization at Application and Client level
 * @param persistenceUnit Persistence Unit/ Comma separated persistence units
 */
private void initializeKundera(String persistenceUnit){
  logger.info("String_Node_Str" + persistenceUnit);
  String[] persistenceUnits=persistenceUnit.split(Constants.PERSISTENCE_UNIT_SEPARATOR);
  (new ApplicationLoader()).load(persistenceUnits);
}
Program: 177045
Project: 177045
Buggy source:
/** 
 * Use this if you want to construct this directly.
 * @param persistenceUnit used to prefix the Cassandra domains
 * @param props should have accessKey and secretKey
 */
public EntityManagerFactoryImpl(String persistenceUnit,Map<String,Object> properties){
  if (properties == null) {
    properties=new HashMap<String,Object>();
  }
  properties.put(Constants.PERSISTENCE_UNIT_NAME,persistenceUnit);
  this.properties=properties;
  this.persistenceUnits=persistenceUnit.split(Constants.PERSISTENCE_UNIT_SEPARATOR);
  cacheProvider=initSecondLevelCache();
  try {
    cacheProvider.createCache(Constants.KUNDERA_SECONDARY_CACHE_NAME);
  }
 catch (  CacheException e) {
    logger.warn("String_Node_Str" + e.getMessage());
  }
  logger.info("String_Node_Str" + persistenceUnit);
}

Fixed version (ground truth):
/** 
 * Use this if you want to construct this directly.
 * @param persistenceUnit used to prefix the Cassandra domains
 * @param props should have accessKey and secretKey
 */
public EntityManagerFactoryImpl(String persistenceUnit,Map<String,Object> properties){
  if (properties == null) {
    properties=new HashMap<String,Object>();
  }
  properties.put(Constants.PERSISTENCE_UNIT_NAME,persistenceUnit);
  this.properties=properties;
  this.persistenceUnits=persistenceUnit.split(Constants.PERSISTENCE_UNIT_SEPARATOR);
  cacheProvider=initSecondLevelCache();
  try {
    cacheProvider.createCache(Constants.KUNDERA_SECONDARY_CACHE_NAME);
  }
 catch (  CacheException e) {
    logger.warn("String_Node_Str" + e.getMessage());
  }
  logger.info("String_Node_Str" + persistenceUnit);
  for (  String pu : persistenceUnits) {
    ClientResolver.getClientFactory(pu).load(pu);
  }
  logger.info("String_Node_Str" + persistenceUnit);
}
Program: 177046
Project: 177046
Buggy source:
/** 
 * Merge.
 * @param < E > the element type
 * @param e the e
 * @return the e
 */
public <E>E merge(E e){
  try {
    List<EnhancedEntity> reachableEntities=EntityResolver.resolve(e,CascadeType.MERGE,getPersistenceUnits());
    for (    EnhancedEntity o : reachableEntities) {
      log.debug("String_Node_Str" + o);
      EntityMetadata m=KunderaMetadataManager.getEntityMetadata(o.getEntity().getClass(),getPersistenceUnits());
      getEventDispatcher().fireEventListeners(m,o,PreUpdate.class);
      persist(o);
      getEventDispatcher().fireEventListeners(m,o,PostUpdate.class);
    }
  }
 catch (  Exception exp) {
    throw new PersistenceException(exp);
  }
  return e;
}

Fixed version (ground truth):
/** 
 * Merge.
 * @param < E > the element type
 * @param e the e
 * @return the e
 */
public <E>E merge(E e){
  try {
    List<EnhancedEntity> reachableEntities=EntityResolver.resolve(e,CascadeType.MERGE,getPersistenceUnits());
    for (    EnhancedEntity o : reachableEntities) {
      log.debug("String_Node_Str" + o);
      EntityMetadata m=KunderaMetadataManager.getEntityMetadata(o.getEntity().getClass(),getPersistenceUnits());
      getEventDispatcher().fireEventListeners(m,o,PreUpdate.class);
      persist(o.getEntity());
      getEventDispatcher().fireEventListeners(m,o,PostUpdate.class);
    }
  }
 catch (  Exception exp) {
    throw new PersistenceException(exp);
  }
  return e;
}
Program: 177048
Project: 177048
Buggy source:
/** 
 * Persist one child entity into persistence store. Also checks whether this child entity has further relationships. If yes, it generates a graph for them and saves them recursively up to "n" level.
 * @param child the child Entity Object.
 * @param objectGraph the object graph to which this child entity belongs.
 */
private void persistOneChildEntity(Object child,EntitySaveGraph objectGraph){
  EntityMetadata metadata=getMetadata(objectGraph.getChildClass());
  List<Relation> relations=metadata.getRelations();
  if (relations == null || relations.isEmpty()) {
    String id=getId(child,metadata);
    objectGraph.setChildId(id);
    if (getSession().lookup(child.getClass(),id) == null) {
      Client chClient=getClient(metadata);
      chClient.persist(child,objectGraph,metadata);
      session.store(id,child);
    }
  }
 else {
    List<EntitySaveGraph> objectGraphs=getGraph(child,metadata);
    for (    EntitySaveGraph graph : objectGraphs) {
      graph.setRevFKeyName(objectGraph.getfKeyName());
      graph.setRevFKeyValue(objectGraph.getParentId());
      graph.setRevParentClass(objectGraph.getParentEntity().getClass());
      saveGraph(graph);
    }
  }
}

Fixed version (ground truth):
/** 
 * Persist one child entity into persistence store. Also checks whether this child entity has further relationships. If yes, it generates a graph for them and saves them recursively up to "n" level.
 * @param child the child Entity Object.
 * @param objectGraph the object graph to which this child entity belongs.
 */
private void persistOneChildEntity(Object child,EntitySaveGraph objectGraph){
  EntityMetadata metadata=getMetadata(objectGraph.getChildClass());
  List<Relation> relations=metadata.getRelations();
  if (relations == null || relations.isEmpty()) {
    String id=getId(child,metadata);
    objectGraph.setChildId(id);
    Client chClient=getClient(metadata);
    chClient.persist(child,objectGraph,metadata);
    session.store(id,child);
  }
 else {
    List<EntitySaveGraph> objectGraphs=getGraph(child,metadata);
    for (    EntitySaveGraph graph : objectGraphs) {
      graph.setRevFKeyName(objectGraph.getfKeyName());
      graph.setRevFKeyValue(objectGraph.getParentId());
      graph.setRevParentClass(objectGraph.getParentEntity().getClass());
      saveGraph(graph);
    }
  }
}
Program: 177049
Project: 177049
Buggy source:
@Override public List<?> getResultList(){
  log.info("String_Node_Str" + query);
  try {
    EntityMetadata m=kunderaQuery.getEntityMetadata();
    Client client=persistenceDelegeator.getClient(m);
    List<EntitySaveGraph> graphs=persistenceDelegeator.getGraph(m.getEntityClazz().newInstance(),m);
    Map<Boolean,List<String>> relationHolder=persistenceDelegeator.getRelations(graphs,m.getEntityClazz());
    List<String> relationNames=relationHolder.values().iterator().next();
    boolean isParent=relationHolder.keySet().iterator().next();
    if (relationNames.isEmpty()) {
      return populateEntities(m,client);
    }
 else {
      return handleAssociations(m,client,graphs,relationNames,isParent);
    }
  }
 catch (  InstantiationException e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
catch (  IllegalAccessException e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
}

Fixed version (ground truth):
@Override public List<?> getResultList(){
  log.info("String_Node_Str" + query);
  List results=null;
  try {
    EntityMetadata m=kunderaQuery.getEntityMetadata();
    Client client=persistenceDelegeator.getClient(m);
    List<EntitySaveGraph> graphs=persistenceDelegeator.getGraph(m.getEntityClazz().newInstance(),m);
    Map<Boolean,List<String>> relationHolder=persistenceDelegeator.getRelations(graphs,m.getEntityClazz());
    List<String> relationNames=relationHolder.values().iterator().next();
    boolean isParent=relationHolder.keySet().iterator().next();
    if (relationNames.isEmpty()) {
      results=populateEntities(m,client);
    }
 else {
      results=handleAssociations(m,client,graphs,relationNames,isParent);
    }
  }
 catch (  InstantiationException e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
catch (  IllegalAccessException e) {
    log.error("String_Node_Str" + e.getMessage());
    throw new QueryHandlerException(e.getMessage());
  }
  return results != null && !results.isEmpty() ? results : null;
}
Program: 177050
Project: 177050
Buggy source:
public final void clear(){
  sessionCache=new ConcurrentHashMap<Object,Object>();
}

Fixed version (ground truth):
public final void clear(){
  sessionCache=new ConcurrentHashMap<Object,Object>();
  if (getL2Cache() != null) {
    getL2Cache().evictAll();
  }
}
Program: 177051
Project: 177051
Buggy source:
/** 
 * Finds ands returns Entity metadata for a given array of PUs
 * @param entityClass
 * @param persistenceUnits
 * @return
 */
public static EntityMetadata getEntityMetadata(Class entityClass,String... persistenceUnits){
  for (  String pu : persistenceUnits) {
    MetamodelImpl metamodel=getMetamodel(pu);
    EntityMetadata metadata=metamodel.getEntityMetadata(entityClass);
    if (metadata != null) {
      return metadata;
    }
  }
  log.warn("String_Node_Str" + entityClass + "String_Node_Str");
  return null;
}

Fixed version (ground truth):
/** 
 * Finds ands returns Entity metadata for a given array of PUs
 * @param entityClass
 * @param persistenceUnits
 * @return
 */
public static EntityMetadata getEntityMetadata(Class entityClass,String... persistenceUnits){
  for (  String pu : persistenceUnits) {
    MetamodelImpl metamodel=getMetamodel(pu);
    EntityMetadata metadata=metamodel.getEntityMetadata(entityClass);
    if (metadata != null) {
      return metadata;
    }
  }
  log.warn("String_Node_Str" + entityClass + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  return null;
}
Program: 177052
Project: 177052
Buggy source:
@Override protected void initializeClient(){
  indexManager=new IndexManager(LuceneIndexer.getInstance(new StandardAnalyzer(Version.LUCENE_34)));
  reader=new RDBMSEntityReader();
}

Fixed version (ground truth):
@Override protected void initializeClient(){
  indexManager=new IndexManager(LuceneIndexer.getInstance(new StandardAnalyzer(Version.LUCENE_34)));
  reader=new RDBMSEntityReader();
  ((RDBMSEntityReader)reader).setFilter("String_Node_Str");
}
Program: 177054
Project: 177054
Buggy source:
private List<EnhanceEntity> populateEnhanceEntities(EntityMetadata m,List<String> relationNames,Client client,String sqlQuery){
  List<EnhanceEntity> ls;
  List<Object[]> result=((HibernateClient)client).find(sqlQuery,relationNames,m.getEntityClazz());
  ls=new ArrayList<EnhanceEntity>(result.size());
  for (  Object[] o : result) {
    EnhanceEntity e=new EnhanceEntity(o[0],getId(o[0],m),populateRelations(relationNames,o));
    ls.add(e);
  }
  return ls;
}

Fixed version (ground truth):
private List<EnhanceEntity> populateEnhanceEntities(EntityMetadata m,List<String> relationNames,Client client,String sqlQuery){
  List<EnhanceEntity> ls;
  boolean isWithNoRelation=relationNames != null && relationNames.isEmpty();
  List result=((HibernateClient)client).find(sqlQuery,relationNames,m.getEntityClazz());
  ls=new ArrayList<EnhanceEntity>(result.size());
  for (  Object o : result) {
    EnhanceEntity e=new EnhanceEntity(isWithNoRelation ? o : ((Object[])o)[0],getId(isWithNoRelation ? o : ((Object[])o)[0],m),isWithNoRelation ? null : populateRelations(relationNames,((Object[])o)));
    ls.add(e);
  }
  return ls;
}
Program: 177055
Project: 177055
Buggy source:
@Override public EnhanceEntity findById(String primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  Set<String> keys=new HashSet<String>(1);
  keys.add(primaryKey);
  String query=getSqlQueryFromJPA(m,relationNames,keys);
  return populateEnhanceEntities(m,relationNames,client,query).get(0);
}

Fixed version (ground truth):
@Override public EnhanceEntity findById(String primaryKey,EntityMetadata m,List<String> relationNames,Client client){
  Set<String> keys=new HashSet<String>(1);
  keys.add(primaryKey);
  String query=getSqlQueryFromJPA(m,relationNames,keys);
  List<EnhanceEntity> results=populateEnhanceEntities(m,relationNames,client,query);
  if (results != null && !results.isEmpty()) {
    return results.get(0);
  }
  return null;
}
Program: 177056
Project: 177056
Buggy source:
/** 
 * On association.
 * @param clazz the clazz
 * @param client the client
 * @param fetchRelation the fetch relation
 * @param query the query
 * @return the list
 */
private List<Object> onAssociation(Class<?> clazz,Client client,boolean fetchRelation,String query,boolean biDirectional,String rowId){
  try {
    IndexManager ixManager=client.getIndexManager();
    Map<String,String> results=fetchRelation ? ixManager.fetchRelation(query) : ixManager.search(query);
    if (biDirectional) {
      results.values().remove(rowId);
    }
    Set<String> rsSet=new HashSet<String>(results.values());
    return (List<Object>)client.find(clazz,rsSet.toArray(new String[]{}));
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * On association.
 * @param clazz the clazz
 * @param client the client
 * @param fetchRelation the fetch relation
 * @param query the query
 * @return the list
 */
private List<Object> onAssociation(Class<?> clazz,Client client,boolean fetchRelation,String query,boolean biDirectional,String rowId){
  try {
    IndexManager ixManager=client.getIndexManager();
    isOpen();
    Map<String,String> results=fetchRelation ? ixManager.fetchRelation(query) : ixManager.search(query);
    if (biDirectional) {
      results.values().remove(rowId);
    }
    Set<String> rsSet=new HashSet<String>(results.values());
    return (List<Object>)client.find(clazz,rsSet.toArray(new String[]{}));
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return null;
}
Program: 177058
Project: 177058
Buggy source:
/** 
 * Populate association.
 * @param entity the entity
 * @param f the f
 * @param childClient the child client
 * @param query the query
 * @param clazz the clazz
 * @return the sets the
 * @throws PropertyAccessException the property access exception
 */
private Set<?> populateAssociation(Object entity,Field f,Client childClient,String query,Class<?> clazz) throws PropertyAccessException {
  List<?> childs=onAssociation(clazz,childClient,true,query,false,null);
  return onReflect(entity,f,childs);
}

Fixed version (ground truth):
/** 
 * Populate association.
 * @param entity the entity
 * @param f the f
 * @param childClient the child client
 * @param query the query
 * @param clazz the clazz
 * @return the sets the
 * @throws PropertyAccessException the property access exception
 */
private Set<?> populateAssociation(Object entity,Field f,Client childClient,String query,Class<?> clazz,boolean fetchRelation) throws PropertyAccessException {
  List<?> childs=onAssociation(clazz,childClient,fetchRelation,query,false,null);
  return onReflect(entity,f,childs);
}
Program: 177059
Project: 177059
Buggy source:
private void onPersist(EntityMetadata entityMetadata,Object entity,String id,List<RelationHolder> relations){
  String dbName=entityMetadata.getSchema();
  String tableName=entityMetadata.getTableName();
  List<String> columnFamilyNames=new ArrayList<String>();
  List<Column> columns=entityMetadata.getColumnsAsList();
  if (columns != null && !columns.isEmpty()) {
    columnFamilyNames.addAll(entityMetadata.getColumnFieldNames());
  }
  columnFamilyNames.addAll(entityMetadata.getEmbeddedColumnFieldNames());
  try {
    handler.createTableIfDoesNotExist(tableName,columnFamilyNames.toArray(new String[0]));
    handler.writeData(tableName,entityMetadata,entity,id,relations);
  }
 catch (  IOException e) {
    throw new PersistenceException(e.getMessage());
  }
}

Fixed version (ground truth):
private void onPersist(EntityMetadata entityMetadata,Object entity,String id,List<RelationHolder> relations){
  String dbName=entityMetadata.getSchema();
  String tableName=entityMetadata.getTableName();
  List<String> columnFamilyNames=new ArrayList<String>();
  List<Column> columns=entityMetadata.getColumnsAsList();
  if (columns != null && !columns.isEmpty()) {
    columnFamilyNames.addAll(entityMetadata.getColumnFieldNames());
  }
  columnFamilyNames.addAll(entityMetadata.getEmbeddedColumnFieldNames());
  if (relations != null) {
    for (    RelationHolder rh : relations) {
      columnFamilyNames.add(rh.getRelationName());
    }
  }
  try {
    handler.createTableIfDoesNotExist(tableName,columnFamilyNames.toArray(new String[0]));
    handler.writeData(tableName,entityMetadata,entity,id,relations);
  }
 catch (  IOException e) {
    throw new PersistenceException(e.getMessage());
  }
}
Program: 177060
Project: 177060
Buggy source:
@Override public void persist(Object childEntity,EntitySaveGraph entitySaveGraph,EntityMetadata entityMetadata){
  String rlName=entitySaveGraph.getfKeyName();
  String rlValue=entitySaveGraph.getParentId();
  String id=entitySaveGraph.getChildId();
  onPersist(entityMetadata,childEntity,id,RelationHolder.addRelation(entitySaveGraph,rlName,rlValue));
}

Fixed version (ground truth):
@Override public void persist(Object childEntity,EntitySaveGraph entitySaveGraph,EntityMetadata entityMetadata){
  String rlName=entitySaveGraph.getfKeyName();
  String rlValue=entitySaveGraph.getParentId();
  String id=entitySaveGraph.getChildId();
  onPersist(entityMetadata,childEntity,id,RelationHolder.addRelation(entitySaveGraph,rlName,rlValue));
  onIndex(childEntity,entitySaveGraph,entityMetadata,rlValue);
}
Program: 177062
Project: 177062
Buggy source:
@Override protected boolean isClientThreadSafe(){
  return false;
}

Fixed version (ground truth):
@Override protected boolean isClientThreadSafe(){
  return true;
}
Program: 177063
Project: 177063
Buggy source:
private void handleRelation(List<RelationHolder> relation,Put p){
  for (  RelationHolder r : relation) {
    if (relation != null) {
      p.add(Bytes.toBytes(r.getRelationName()),System.currentTimeMillis(),Bytes.toBytes(r.getRelationValue()));
    }
  }
}

Fixed version (ground truth):
private void handleRelation(List<RelationHolder> relation,Put p){
  if (relation != null) {
    for (    RelationHolder r : relation) {
      if (relation != null) {
        p.add(Bytes.toBytes(r.getRelationName()),System.currentTimeMillis(),Bytes.toBytes(r.getRelationValue()));
      }
    }
  }
}
Program: 177064
Project: 177064
Buggy source:
@Override public EntitySaveGraph handleAssociation(Object entity,Object associatedEntity,EntityMetadata metadata,Relation relation){
  Field rField=relation.getProperty();
  EntitySaveGraph objectGraph=populateDefaultGraph(entity,associatedEntity,rField);
  isSharedByPrimaryKey(entity,rField,objectGraph,associatedEntity,metadata);
  onDetach(entity,associatedEntity,relation.getProperty(),true);
  objectGraph.setProperty(rField);
  return objectGraph;
}

Fixed version (ground truth):
@Override public EntitySaveGraph handleAssociation(Object entity,Object associatedEntity,EntityMetadata metadata,Relation relation){
  Field rField=relation.getProperty();
  EntitySaveGraph objectGraph=populateDefaultGraph(entity,associatedEntity,rField);
  isSharedByPrimaryKey(entity,rField,objectGraph,associatedEntity,metadata);
  computeDirection(entity,relation.getProperty(),objectGraph,OneToOne.class);
  onDetach(entity,associatedEntity,relation.getProperty(),true);
  objectGraph.setProperty(rField);
  return objectGraph;
}
Program: 177066
Project: 177066
Buggy source:
/** 
 * Index super column.
 * @param metadata the metadata
 * @param object the object
 * @param currentDoc the current doc
 * @param embeddedObject the embedded object
 * @param superColumn the super column
 */
protected void indexSuperColumn(EntityMetadata metadata,Object object,Document currentDoc,Object embeddedObject,EmbeddedColumn superColumn){
  for (  Column col : superColumn.getColumns()) {
    java.lang.reflect.Field field=col.getField();
    String colName=col.getName();
    String indexName=metadata.getIndexName();
    addFieldToDocument(embeddedObject,currentDoc,field,colName,indexName);
  }
  addFieldsToDocument(metadata,object,currentDoc);
  indexDocument(metadata,currentDoc);
}

Fixed version (ground truth):
/** 
 * Index super column.
 * @param metadata the metadata
 * @param object the object
 * @param currentDoc the current doc
 * @param embeddedObject the embedded object
 * @param superColumn the super column
 */
protected void indexSuperColumn(EntityMetadata metadata,Object object,Document currentDoc,Object embeddedObject,EmbeddedColumn superColumn){
  for (  Column col : superColumn.getColumns()) {
    java.lang.reflect.Field field=col.getField();
    String colName=field.getName();
    String indexName=metadata.getIndexName();
    addFieldToDocument(embeddedObject,currentDoc,field,colName,indexName);
  }
  addFieldsToDocument(metadata,object,currentDoc);
  indexDocument(metadata,currentDoc);
}
Program: 177067
Project: 177067
Buggy source:
@Override protected void initializeClient(){
  logger.info("String_Node_Str");
  indexManager=new IndexManager(new LuceneIndexer(new StandardAnalyzer(Version.LUCENE_34)));
}

Fixed version (ground truth):
@Override protected void initializeClient(){
  logger.info("String_Node_Str");
  indexManager=new IndexManager(new LuceneIndexer(new KeywordAnalyzer()));
}
Program: 177070
Project: 177070
Buggy source:
public final void close(){
  eventDispatcher=null;
  persistenceUnits=null;
  for (  Client client : clientMap.values()) {
    client.close();
  }
  closed=true;
}

Fixed version (ground truth):
public final void close(){
  eventDispatcher=null;
  persistenceUnits=null;
  if (clientMap != null && !clientMap.isEmpty()) {
    for (    Client client : clientMap.values()) {
      client.close();
    }
  }
  closed=true;
}
Program: 177071
Project: 177071
Buggy source:
/** 
 * Instantiates a new lucandra indexer.
 * @param client the client
 * @param analyzer the analyzer
 */
public DocumentIndexer(Analyzer analyzer){
  this.analyzer=analyzer;
}

Fixed version (ground truth):
/** 
 * Instantiates a new lucandra indexer.
 * @param client the client
 * @param analyzer the analyzer
 */
public DocumentIndexer(Analyzer analyzer){
  final String empty="String_Node_Str";
  this.analyzer=analyzer;
  tokenizer=new LetterTokenizer(Version.LUCENE_34,new CharArrayReader(empty.toCharArray()));
}
Program: 177072
Project: 177072
Buggy source:
/** 
 * Index super column name.
 * @param superColumnName the super column name
 * @param currentDoc the current doc
 */
private void addEmbeddedColumnNameToDocument(String superColumnName,Document currentDoc){
  byte[] value=superColumnName.getBytes();
  Field luceneField=new Field(SUPERCOLUMN_INDEX,value,0,value.length);
  currentDoc.add(luceneField);
}

Fixed version (ground truth):
/** 
 * Index super column name.
 * @param superColumnName the super column name
 * @param currentDoc the current doc
 */
private void addEmbeddedColumnNameToDocument(String superColumnName,Document currentDoc){
  Field luceneField=getLuceneField(SUPERCOLUMN_INDEX,superColumnName);
  currentDoc.add(luceneField);
}
Program: 177073
Project: 177073
Buggy source:
/** 
 * Index field.
 * @param object the object
 * @param document the document
 * @param field the field
 * @param colName the col name
 * @param indexName the index name
 */
private void addFieldToDocument(Object object,Document document,java.lang.reflect.Field field,String colName,String indexName){
  try {
    String value=PropertyAccessorHelper.getString(object,field);
    if (value != null) {
      byte[] val=value.getBytes();
      Field luceneField=new Field(getCannonicalPropertyName(indexName,colName),val,0,val.length);
      luceneField.setOmitNorms(true);
      document.add(luceneField);
    }
 else {
      LOG.warn("String_Node_Str" + field.getName());
    }
  }
 catch (  PropertyAccessException e) {
    LOG.error("String_Node_Str" + e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Index field.
 * @param object the object
 * @param document the document
 * @param field the field
 * @param colName the col name
 * @param indexName the index name
 */
private void addFieldToDocument(Object object,Document document,java.lang.reflect.Field field,String colName,String indexName){
  try {
    String value=PropertyAccessorHelper.getString(object,field);
    if (value != null) {
      Field luceneField=getLuceneField(getCannonicalPropertyName(indexName,colName),value);
      document.add(luceneField);
    }
 else {
      LOG.warn("String_Node_Str" + field.getName());
    }
  }
 catch (  PropertyAccessException e) {
    LOG.error("String_Node_Str" + e.getMessage());
  }
}
Program: 177074
Project: 177074
Buggy source:
/** 
 * Prepare index document.
 * @param metadata the metadata
 * @param object the object
 * @param document the document
 */
protected void addEntityClassToDocument(EntityMetadata metadata,Object object,Document document){
  try {
    Field luceneField;
    String id;
    id=PropertyAccessorHelper.getId(object,metadata);
    byte[] value=id.getBytes();
    luceneField=new Field(ENTITY_ID_FIELD,value,0,value.length);
    luceneField.setOmitNorms(true);
    document.add(luceneField);
    value=getKunderaId(metadata,id).getBytes();
    luceneField=new Field(KUNDERA_ID_FIELD,value,0,value.length);
    luceneField.setOmitNorms(true);
    document.add(luceneField);
    value=metadata.getEntityClazz().getCanonicalName().toLowerCase().getBytes();
    luceneField=new Field(ENTITY_CLASS_FIELD,value,0,value.length);
    luceneField.setOmitNorms(true);
    document.add(luceneField);
    value=metadata.getIndexName().getBytes();
    luceneField=new Field(ENTITY_INDEXNAME_FIELD,value,0,value.length);
    luceneField.setOmitNorms(true);
    document.add(luceneField);
  }
 catch (  PropertyAccessException e) {
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Prepare index document.
 * @param metadata the metadata
 * @param object the object
 * @param document the document
 */
protected void addEntityClassToDocument(EntityMetadata metadata,Object object,Document document){
  try {
    Field luceneField;
    String id;
    id=PropertyAccessorHelper.getId(object,metadata);
    luceneField=getLuceneField(ENTITY_ID_FIELD,id);
    document.add(luceneField);
    luceneField=getLuceneField(KUNDERA_ID_FIELD,getKunderaId(metadata,id));
    document.add(luceneField);
    luceneField=getLuceneField(ENTITY_CLASS_FIELD,metadata.getEntityClazz().getCanonicalName().toLowerCase());
    document.add(luceneField);
    luceneField=getLuceneField(ENTITY_INDEXNAME_FIELD,metadata.getIndexName());
    document.add(luceneField);
  }
 catch (  PropertyAccessException e) {
    throw new IllegalArgumentException("String_Node_Str");
  }
}
Program: 177075
Project: 177075
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public final Map<String,String> search(String luceneQuery,int start,int count){
  getIndexReader();
  if (Constants.INVALID == count) {
    count=100;
  }
  log.debug("String_Node_Str" + luceneQuery + "String_Node_Str"+ start+ "String_Node_Str"+ count);
  Map<String,String> indexCol=new HashMap<String,String>();
  if (reader == null) {
    throw new RuntimeException("String_Node_Str");
  }
  IndexSearcher searcher=new IndexSearcher(reader);
  QueryParser qp=new QueryParser(Version.LUCENE_CURRENT,DEFAULT_SEARCHABLE_FIELD,analyzer);
  try {
    Query q=qp.parse(luceneQuery);
    TopDocs docs=searcher.search(q,count);
    int nullCount=0;
    for (    ScoreDoc sc : docs.scoreDocs) {
      Document doc=searcher.doc(sc.doc);
      String entityId=doc.get(ENTITY_ID_FIELD);
      String superCol=doc.get(SUPERCOLUMN_INDEX);
      if (superCol == null) {
        superCol="String_Node_Str" + nullCount++;
      }
      indexCol.put(superCol,entityId);
    }
  }
 catch (  ParseException e) {
    new IndexingException(e.getMessage());
  }
catch (  IOException e) {
    new IndexingException(e.getMessage());
  }
  return indexCol;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public final Map<String,String> search(String luceneQuery,int start,int count){
  getIndexReader();
  if (Constants.INVALID == count) {
    count=100;
  }
  log.debug("String_Node_Str" + luceneQuery + "String_Node_Str"+ start+ "String_Node_Str"+ count);
  Map<String,String> indexCol=new HashMap<String,String>();
  if (reader == null) {
    throw new RuntimeException("String_Node_Str");
  }
  IndexSearcher searcher=new IndexSearcher(reader);
  QueryParser qp=new QueryParser(Version.LUCENE_34,DEFAULT_SEARCHABLE_FIELD,new KeywordAnalyzer());
  try {
    qp.setLowercaseExpandedTerms(false);
    qp.setAllowLeadingWildcard(true);
    Query q=qp.parse(luceneQuery);
    TopDocs docs=searcher.search(q,count);
    int nullCount=0;
    for (    ScoreDoc sc : docs.scoreDocs) {
      Document doc=searcher.doc(sc.doc);
      String entityId=doc.get(ENTITY_ID_FIELD);
      String superCol=doc.get(SUPERCOLUMN_INDEX);
      if (superCol == null) {
        superCol="String_Node_Str" + nullCount++;
      }
      indexCol.put(superCol,entityId);
    }
  }
 catch (  ParseException e) {
    new IndexingException(e.getMessage());
  }
catch (  IOException e) {
    new IndexingException(e.getMessage());
  }
  return indexCol;
}
Program: 177076
Project: 177076
Buggy source:
/** 
 * Indexes document in file system using lucene
 * @param document
 * @throws CorruptIndexException
 * @throws IOException
 */
public void indexDocumentUsingLucene(Document document){
  IndexWriter w=getIndexWriter();
  try {
    w.addDocument(document);
  }
 catch (  CorruptIndexException e) {
    log.error("String_Node_Str" + document + "String_Node_Str"+ e.getMessage());
  }
catch (  IOException e) {
    log.error("String_Node_Str" + document + "String_Node_Str"+ e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Indexes document in file system using lucene
 * @param document
 * @throws CorruptIndexException
 * @throws IOException
 */
private void indexDocumentUsingLucene(Document document){
  IndexWriter w=getIndexWriter();
  try {
    w.addDocument(document);
  }
 catch (  CorruptIndexException e) {
    log.error("String_Node_Str" + document + "String_Node_Str"+ e.getMessage());
  }
catch (  IOException e) {
    log.error("String_Node_Str" + document + "String_Node_Str"+ e.getMessage());
  }
}
Program: 177077
Project: 177077
Buggy source:
/** 
 * Creates a Lucene index directory if it does not exist.
 * @return the index directory
 */
private File getIndexDirectory(){
  String filePath=System.getProperty("String_Node_Str") + LUCENE_INDEX_DIRECTORY_NAME;
  File file=new File(filePath);
  if (!file.isDirectory()) {
    file.mkdir();
  }
  return file;
}

Fixed version (ground truth):
/** 
 * Creates a Lucene index directory if it does not exist.
 * @return the index directory
 */
private File getIndexDirectory(){
  String filePath=System.getProperty("String_Node_Str") + "String_Node_Str" + LUCENE_INDEX_DIRECTORY_NAME;
  File file=new File(filePath);
  if (!file.isDirectory()) {
    file.mkdir();
  }
  return file;
}
Program: 177078
Project: 177078
Buggy source:
/** 
 * Creates a string representation of a set of foreign keys by combining them together separated by "~" character. Note: Assumption is that @Id will never contain "~" character. Checks for this are not added yet.
 * @param foreignKeys the foreign keys
 * @return the string
 */
public static String serializeKeys(Set<String> foreignKeys){
  if (null == foreignKeys || foreignKeys.isEmpty()) {
    return null;
  }
  StringBuilder sb=new StringBuilder();
  for (  String key : foreignKeys) {
    if (sb.length() > 0) {
      sb.append(Constants.SEPARATOR);
    }
    sb.append(key);
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Creates a string representation of a set of foreign keys by combining them together separated by "~" character. Note: Assumption is that @Id will never contain "~" character. Checks for this are not added yet.
 * @param foreignKeys the foreign keys
 * @return the string
 */
public static String serializeKeys(Set<String> foreignKeys){
  if (null == foreignKeys || foreignKeys.isEmpty()) {
    return null;
  }
  StringBuilder sb=new StringBuilder();
  for (  String key : foreignKeys) {
    if (sb.length() > 0) {
      sb.append(Constants.FOREIGN_KEY_SEPARATOR);
    }
    sb.append(key);
  }
  return sb.toString();
}
Program: 177079
Project: 177079
Buggy source:
/** 
 * Splits foreign keys into Set.
 * @param foreignKeys the foreign keys
 * @return the set
 */
public static Set<String> deserializeKeys(String foreignKeys){
  Set<String> keys=new HashSet<String>();
  if (null == foreignKeys || foreignKeys.isEmpty()) {
    return keys;
  }
  String array[]=foreignKeys.split(Constants.SEPARATOR);
  for (  String element : array) {
    keys.add(element);
  }
  return keys;
}

Fixed version (ground truth):
/** 
 * Splits foreign keys into Set.
 * @param foreignKeys the foreign keys
 * @return the set
 */
public static Set<String> deserializeKeys(String foreignKeys){
  Set<String> keys=new HashSet<String>();
  if (null == foreignKeys || foreignKeys.isEmpty()) {
    return keys;
  }
  String array[]=foreignKeys.split(Constants.FOREIGN_KEY_SEPARATOR);
  for (  String element : array) {
    keys.add(element);
  }
  return keys;
}
Program: 177080
Project: 177080
Buggy source:
public void writeColumns(HTable htable,String rowKey,List<Column> columns,Object entity) throws IOException ;

Fixed version (ground truth):
/** 
 * Writes Columns <code>columns</code> into a given table. Each columns is written in their own column family(name same as column name)
 * @param htable
 * @param rowKey
 * @param columns Columns of a given table (No column family given)
 * @param entity
 * @throws IOException
 */
public void writeColumns(HTable htable,String rowKey,List<Column> columns,Object entity) throws IOException ;
Program: 177082
Project: 177082
Buggy source:
@Override public <E>E readData(final String tableName,Class<E> clazz,EntityMetadata m,final String rowKey) throws IOException {
  E e=null;
  try {
    e=clazz.newInstance();
    HBaseData data=hbaseReader.LoadData(gethTable(tableName),rowKey);
    populateEntityFromHbaseData(e,data,m,rowKey);
  }
 catch (  InstantiationException e1) {
    log.error("String_Node_Str" + clazz);
    return e;
  }
catch (  IllegalAccessException e1) {
    log.error("String_Node_Str" + tableName + "String_Node_Str"+ e1.getMessage());
    return e;
  }
  return e;
}

Fixed version (ground truth):
@Override public <E>E readData(final String tableName,Class<E> clazz,EntityMetadata m,final String rowKey) throws IOException {
  E enhancedEntity=null;
  try {
    E entity=clazz.newInstance();
    HBaseData data=hbaseReader.LoadData(gethTable(tableName),rowKey);
    populateEntityFromHbaseData(entity,data,m,rowKey);
    Map<String,Set<String>> foreignKeysMap=new HashMap<String,Set<String>>();
    enhancedEntity=(E)EntityResolver.getEnhancedEntity(entity,rowKey,foreignKeysMap);
  }
 catch (  InstantiationException e1) {
    log.error("String_Node_Str" + clazz);
    return enhancedEntity;
  }
catch (  IllegalAccessException e1) {
    log.error("String_Node_Str" + tableName + "String_Node_Str"+ e1.getMessage());
    return enhancedEntity;
  }
  return enhancedEntity;
}
Program: 177084
Project: 177084
Buggy source:
@Override public void shutdown(){
  try {
    admin.shutdown();
  }
 catch (  IOException e) {
    throw new RuntimeException(e.getMessage());
  }
}

Fixed version (ground truth):
@Override public void shutdown(){
}
Program: 177085
Project: 177085
Buggy source:
/** 
 * Immediate load and cache.
 * @param < E > the element type
 * @param entityClass the entity class
 * @param primaryKey the primary key
 * @return the e
 */
protected <E>E immediateLoadAndCache(Class<E> entityClass,Object primaryKey){
  try {
    EntityMetadata m=metadataManager.getEntityMetadata(entityClass);
    m.setDBType(this.client.getType());
    E e=client.loadData(this,primaryKey.toString(),m);
    if (e != null) {
      session.store(primaryKey,e,m.isCacheable());
    }
    return e;
  }
 catch (  Exception exp) {
    throw new PersistenceException(exp);
  }
}

Fixed version (ground truth):
/** 
 * Immediate load and cache.
 * @param < E > the element type
 * @param entityClass the entity class
 * @param primaryKey the primary key
 * @return the e
 */
protected <E>E immediateLoadAndCache(Class<E> entityClass,Object primaryKey){
  try {
    EntityMetadata m=metadataManager.getEntityMetadata(entityClass);
    m.setDBType(this.client.getType());
    E e=(E)client.loadData(this,primaryKey.toString(),m);
    if (e != null) {
      session.store(primaryKey,e,m.isCacheable());
    }
    return e;
  }
 catch (  Exception exp) {
    throw new PersistenceException(exp);
  }
}
Program: 177086
Project: 177086
Buggy source:
/** 
 * Instantiates a new entity manager impl.
 * @param factory the factory
 * @param client the client
 */
public EntityManagerImpl(EntityManagerFactoryImpl factory){
  this.factory=factory;
  this.metadataManager=factory.getMetadataManager();
  this.persistenceUnitName=factory.getPersistenceUnitName();
  dataManager=new DataManager(this);
  entityResolver=new EntityResolver(this);
  session=new EntityManagerSession(this);
  eventDispatcher=new EntityEventDispatcher();
}

Fixed version (ground truth):
/** 
 * Instantiates a new entity manager impl.
 * @param factory the factory
 * @param client the client
 */
public EntityManagerImpl(EntityManagerFactoryImpl factory){
  this.factory=factory;
  this.metadataManager=factory.getMetadataManager();
  this.persistenceUnitName=factory.getPersistenceUnitName();
  entityResolver=new EntityResolver(this);
  session=new EntityManagerSession(this);
  eventDispatcher=new EntityEventDispatcher();
}
Program: 177087
Project: 177087
Buggy source:
public void persistData(EnhancedEntity e){
  try {
    EntityMetadata metadata=getMetadataManager().getEntityMetadata(e.getEntity().getClass());
    String persistenceUnit=metadata.getPersistenceUnit();
    setClient(((EntityManagerImpl)new Configuration().getEntityManager(persistenceUnit)).getClient());
    metadata.setDBType(getClient().getType());
    getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
    getDataManager().persist(e,metadata);
    getIndexManager().write(metadata,e.getEntity());
    getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
  }
 catch (  PersistenceException ex) {
    log.error("String_Node_Str" + ex.getMessage());
    throw ex;
  }
catch (  Exception ex) {
    ex.printStackTrace();
    throw new PersistenceException(ex.getMessage());
  }
}

Fixed version (ground truth):
public void persistData(EnhancedEntity e){
  try {
    EntityMetadata metadata=getMetadataManager().getEntityMetadata(e.getEntity().getClass());
    metadata.setDBType(getClient().getType());
    getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
    getDataManager().persist(e,metadata);
    getIndexManager().write(metadata,e.getEntity());
    getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
  }
 catch (  PersistenceException ex) {
    log.error("String_Node_Str" + ex.getMessage());
    throw ex;
  }
catch (  Exception ex) {
    ex.printStackTrace();
    throw new PersistenceException(ex.getMessage());
  }
}
Program: 177088
Project: 177088
Buggy source:
/** 
 * Populate foreign entities.
 * @param containingEntity the containing entity
 * @param containingEntityId the containing entity id
 * @param relation the relation
 * @param foreignKeys the foreign keys
 * @throws PropertyAccessException the property access exception
 */
public void populateForeignEntities(Object entity,String entityId,Relation relation,String... foreignKeys) throws PropertyAccessException {
  if (null == foreignKeys || foreignKeys.length == 0) {
    return;
  }
  String entityName=entity.getClass().getName() + "String_Node_Str" + entityId+ "String_Node_Str"+ relation.getProperty().getName();
  LOG.debug("String_Node_Str" + entityName);
  Class<?> foreignEntityClass=relation.getTargetEntity();
  em.getSession().store(entity,entityId,Boolean.FALSE);
  EntityMetadata relMetadata=em.getMetadataManager().getEntityMetadata(foreignEntityClass);
  if (em.getPersistenceUnitName().equals(relMetadata.getPersistenceUnit())) {
    populateForeignEntityFromSameDatastore(entity,relation,entityName,foreignEntityClass,foreignKeys);
  }
 else {
    LOG.debug("String_Node_Str");
    populateForeignEntityFromDifferentDatastore(entity,relation,entityName,foreignEntityClass,foreignKeys);
  }
}

Fixed version (ground truth):
/** 
 * Populate foreign entities.
 * @param containingEntity the containing entity
 * @param containingEntityId the containing entity id
 * @param relation the relation
 * @param foreignKeys the foreign keys
 * @throws PropertyAccessException the property access exception
 */
public void populateForeignEntities(Object entity,String entityId,Relation relation,String... foreignKeys) throws PropertyAccessException {
  if (null == foreignKeys || foreignKeys.length == 0) {
    return;
  }
  String entityName=entity.getClass().getName() + "String_Node_Str" + entityId+ "String_Node_Str"+ relation.getProperty().getName();
  LOG.debug("String_Node_Str" + entityName);
  Class<?> foreignEntityClass=relation.getTargetEntity();
  em.getSession().store(entity,entityId,Boolean.FALSE);
  EntityMetadata relMetadata=em.getMetadataManager().getEntityMetadata(foreignEntityClass);
  if (relMetadata.getPersistenceUnit() == null || em.getPersistenceUnitName().equals(relMetadata.getPersistenceUnit())) {
    populateForeignEntityFromSameDatastore(entity,relation,entityName,foreignEntityClass,foreignKeys);
  }
 else {
    LOG.debug("String_Node_Str");
    populateForeignEntityFromDifferentDatastore(entity,relation,entityName,foreignEntityClass,foreignKeys);
  }
}
Program: 177089
Project: 177089
Buggy source:
public void persistData(EnhancedEntity e){
  try {
    EntityMetadata metadata=getMetadataManager().getEntityMetadata(e.getEntity().getClass());
    String persistenceUnit=metadata.getPersistenceUnit();
    if (persistenceUnit != null && !persistenceUnit.equals(getPersistenceUnitName())) {
      setClient(((EntityManagerImpl)new Configuration().getEntityManager(persistenceUnit)).getClient());
    }
    metadata.setDBType(getClient().getType());
    getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
    getDataManager().persist(e,metadata);
    getIndexManager().write(metadata,e.getEntity());
    getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
  }
 catch (  PersistenceException ex) {
    log.error("String_Node_Str" + ex.getMessage());
    throw ex;
  }
catch (  Exception ex) {
    ex.printStackTrace();
    throw new PersistenceException(ex.getMessage());
  }
}

Fixed version (ground truth):
public void persistData(EnhancedEntity e){
  try {
    EntityMetadata metadata=getMetadataManager().getEntityMetadata(e.getEntity().getClass());
    String persistenceUnit=metadata.getPersistenceUnit();
    setClient(((EntityManagerImpl)new Configuration().getEntityManager(persistenceUnit)).getClient());
    metadata.setDBType(getClient().getType());
    getEventDispatcher().fireEventListeners(metadata,e,PrePersist.class);
    getDataManager().persist(e,metadata);
    getIndexManager().write(metadata,e.getEntity());
    getEventDispatcher().fireEventListeners(metadata,e,PostPersist.class);
  }
 catch (  PersistenceException ex) {
    log.error("String_Node_Str" + ex.getMessage());
    throw ex;
  }
catch (  Exception ex) {
    ex.printStackTrace();
    throw new PersistenceException(ex.getMessage());
  }
}