nus-yam/ex-repair huggingface dataset:
Program: 2535
Project: 2535
Buggy source:
/** 
 * Read the field from the query result into the opject within the state manager.
 * @param stateManager
 * @param result
 * @return True if the field was loaded. False otherwise
 */
@SuppressWarnings("String_Node_Str") public boolean readField(OpenJPAStateManager stateManager,QueryResult<ColumnSlice<String,byte[]>> result){
  HColumn<String,byte[]> column=result.get().getColumnByName(name);
  if (column == null) {
    stateManager.store(fieldId,null);
    return false;
  }
  DynamicComposite composite=serializer.fromBytes(column.getValue());
  Collection<Object> collection=(Collection<Object>)stateManager.newFieldProxy(fieldId);
  int size=composite.get(0,intSerializer);
  for (int i=1; i <= size; i++) {
    Object value=embeddedSerializer.getObject(composite.getComponent(i).getBytes());
    collection.add(value);
  }
  stateManager.store(fieldId,collection);
  return true;
}

Fixed version (ground truth):
/** 
 * Read the field from the query result into the opject within the state manager.
 * @param stateManager
 * @param result
 * @return True if the field was loaded. False otherwise
 */
@SuppressWarnings("String_Node_Str") public boolean readField(OpenJPAStateManager stateManager,QueryResult<ColumnSlice<String,byte[]>> result){
  HColumn<String,byte[]> column=result.get().getColumnByName(name);
  if (column == null) {
    stateManager.store(fieldId,null);
    return false;
  }
  DynamicComposite composite=serializer.fromBytes(column.getValue());
  Collection<Object> collection=(Collection<Object>)stateManager.newFieldProxy(fieldId);
  int size=composite.get(0,intSerializer);
  for (int i=1; i <= size; i++) {
    Object value=embeddedSerializer.getObject(composite.getComponent(i).getBytes());
    if (value == null) {
      continue;
    }
    collection.add(value);
  }
  stateManager.store(fieldId,collection);
  return true;
}
Program: 2536
Project: 2536
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public <T>T getObject(ByteBuffer bytes){
  try {
    ByteBufferInputStream input=new ByteBufferInputStream(bytes);
    XStream xstream=new XStream();
    T result=(T)xstream.fromXML(input);
    input.close();
    return result;
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public <T>T getObject(ByteBuffer bytes){
  try {
    ByteBufferInputStream input=new ByteBufferInputStream(bytes);
    XStream xstream=new XStream();
    T result=(T)xstream.fromXML(input);
    input.close();
    return result;
  }
 catch (  Exception e) {
    return null;
  }
}
Program: 2537
Project: 2537
Buggy source:
/** 
 * Compare 2 index definitions. Index definitions are compared in the following way If an order is defined, then all order fields must be preset and in the same order for order comparison to == 0 If these orders are not the same, the shortest number of order operands is returned as less. If the order operands are the same, the fields are compared. The fields follow the same logic of operands Indexes with less fields are returned with < 0 to encourage the use of shorter rows for faster querying Not a null safe comparator
 * @author Todd Nine
 */
@Override public int compareTo(IndexDefinition def2){
  int compare=0;
  IndexOrder[] def2Order=def2.getOrderFields();
  if (orderFields.length > def2Order.length) {
    return 1;
  }
 else   if (orderFields.length < def2Order.length) {
    return -1;
  }
  for (int i=0; i < orderFields.length; i++) {
    compare=orderFields[i].getName().compareTo(def2Order[i].getName());
    if (compare != 0) {
      return compare;
    }
  }
  FieldOrder[] def2Field=def2.getIndexedFields();
  if (indexedFields.length > def2Field.length) {
    return 1;
  }
 else   if (indexedFields.length < def2Field.length) {
    return -1;
  }
  int matchCount=0;
  for (int i=0; i < indexedFields.length; i++) {
    for (int j=0; j < def2Field.length; j++) {
      if (indexedFields[i].getName().equals(def2Field[j].getName())) {
        matchCount++;
        break;
      }
    }
  }
  return matchCount - indexedFields.length;
}

Fixed version (ground truth):
/** 
 * Compare 2 index definitions. Index definitions are compared in the following way If an order is defined, then all order fields must be preset and in the same order for order comparison to == 0 If these orders are not the same, the shortest number of order operands is returned as less. If the order operands are the same, the fields are compared. The fields follow the same logic of operands Indexes with less fields are returned with < 0 to encourage the use of shorter rows for faster querying Not a null safe comparator
 * @author Todd Nine
 */
@Override public int compareTo(IndexDefinition def2){
  int compare=0;
  IndexOrder[] def2Order=def2.getOrderFields();
  if (def2Order.length > 0)   if (orderFields.length > def2Order.length) {
    return 1;
  }
 else   if (orderFields.length < def2Order.length) {
    return -1;
  }
  for (int i=0; i < orderFields.length; i++) {
    compare=orderFields[i].getName().compareTo(def2Order[i].getName());
    if (compare != 0) {
      return compare;
    }
  }
  FieldOrder[] def2Field=def2.getIndexedFields();
  if (indexedFields.length > def2Field.length) {
    return 1;
  }
 else   if (indexedFields.length < def2Field.length) {
    return -1;
  }
  int matchCount=0;
  for (int i=0; i < indexedFields.length; i++) {
    for (int j=0; j < def2Field.length; j++) {
      if (indexedFields[i].getName().equals(def2Field[j].getName())) {
        matchCount++;
        break;
      }
    }
  }
  return matchCount - indexedFields.length;
}
Program: 2538
Project: 2538
Buggy source:
@Override public Object getResultObject() throws Exception {
  DynamicComposite current=iterator.next();
  int length=current.getComponents().size();
  Object id=current.get(length - 1,idSerializer);
  Object jpaId=ctx.newObjectId(classMeta.getDescribedType(),id);
  return ctx.find(jpaId,fetchConfig,null,null,0);
}

Fixed version (ground truth):
@Override public Object getResultObject() throws Exception {
  DynamicComposite current=iterator.next();
  int length=current.getComponents().size();
  Object id=keyStrategy.getInstance(current.getComponent(length - 1).getBytes());
  Object jpaId=ctx.newObjectId(classMeta.getDescribedType(),id);
  return ctx.find(jpaId,fetchConfig,null,null,0);
}
Program: 2539
Project: 2539
Buggy source:
public CassandraResultObjectProvider(Set<DynamicComposite> results,StoreContext ctx,FetchConfiguration fetchConfig,CassandraClassMetaData classMeta){
  this.results=results;
  this.ctx=ctx;
  this.classMeta=classMeta;
  this.fetchConfig=fetchConfig;
  idSerializer=MappingUtils.getSerializerForPk(classMeta);
}

Fixed version (ground truth):
public CassandraResultObjectProvider(Set<DynamicComposite> results,StoreContext ctx,FetchConfiguration fetchConfig,CassandraClassMetaData classMeta){
  this.results=results;
  this.ctx=ctx;
  this.classMeta=classMeta;
  this.fetchConfig=fetchConfig;
  keyStrategy=MappingUtils.getKeyStrategy(classMeta);
}
Program: 2541
Project: 2541
Buggy source:
@Override public void enter(Value val){
  log.debug("String_Node_Str",val);
  if (val instanceof CandidatePath) {
    field=((CandidatePath)val).last();
    log.debug("String_Node_Str",field.getName(),field);
    return;
  }
  if (val instanceof Literal) {
    value=((Literal)val).getValue();
  }
 else   if (val instanceof Parameter) {
    log.debug("String_Node_Str",val);
  }
}

Fixed version (ground truth):
@Override public void enter(Value val){
  log.debug("String_Node_Str",val);
  if (val instanceof CandidatePath) {
    field=((CandidatePath)val).last();
    log.debug("String_Node_Str",field.getName(),field);
    return;
  }
  if (val instanceof Literal) {
    value=((Literal)val).getValue();
  }
 else   if (val instanceof Parameter) {
    log.debug("String_Node_Str",val);
    value=((Parameter)val).getValue(params);
  }
}
Program: 2542
Project: 2542
Buggy source:
public IndexExpressionVisitor(CassandraClassMetaData classMetaData){
  this.classMetaData=classMetaData;
  this.queries.add(new IndexQuery(this.classMetaData));
  this.currentIndex=0;
}

Fixed version (ground truth):
public IndexExpressionVisitor(CassandraClassMetaData classMetaData,Object[] params){
  this.classMetaData=classMetaData;
  this.params=params;
  this.queries.add(new IndexQuery(this.classMetaData));
  this.currentIndex=0;
}
Program: 2543
Project: 2543
Buggy source:
/** 
 * Search multiple items with the in operator
 */
@Test public void namedQueryWithIn(){
  EntityManager em=entityManagerFactory.createEntityManager();
  em.getTransaction().begin();
  Store fifth=new Store();
  fifth.setName("String_Node_Str");
  em.persist(fifth);
  Store fourth=new Store();
  fourth.setName("String_Node_Str");
  em.persist(fourth);
  Store third=new Store();
  third.setName("String_Node_Str");
  em.persist(third);
  System.out.println(third.getName());
  Store second=new Store();
  second.setName("String_Node_Str");
  em.persist(second);
  Store first=new Store();
  first.setName("String_Node_Str");
  em.persist(first);
  em.getTransaction().commit();
  em.close();
  EntityManager em2=entityManagerFactory.createEntityManager();
  em2.getTransaction().begin();
  Query query=em2.createNamedQuery("String_Node_Str");
  ArrayList<String> names=new ArrayList<String>();
  names.add("String_Node_Str");
  names.add("String_Node_Str");
  query.setParameter("String_Node_Str","String_Node_Str");
  Store found=(Store)query.getResultList().get(0);
  assertEquals(third,found);
  em2.getTransaction().commit();
  em2.close();
}

Fixed version (ground truth):
/** 
 * Search multiple items with the in operator
 */
@Test @Ignore public void namedQueryWithIn(){
  EntityManager em=entityManagerFactory.createEntityManager();
  em.getTransaction().begin();
  Store fifth=new Store();
  fifth.setName("String_Node_Str");
  em.persist(fifth);
  Store fourth=new Store();
  fourth.setName("String_Node_Str");
  em.persist(fourth);
  Store third=new Store();
  third.setName("String_Node_Str");
  em.persist(third);
  System.out.println(third.getName());
  Store second=new Store();
  second.setName("String_Node_Str");
  em.persist(second);
  Store first=new Store();
  first.setName("String_Node_Str");
  em.persist(first);
  em.getTransaction().commit();
  em.close();
  EntityManager em2=entityManagerFactory.createEntityManager();
  em2.getTransaction().begin();
  Query query=em2.createNamedQuery("String_Node_Str");
  ArrayList<String> names=new ArrayList<String>();
  names.add("String_Node_Str");
  names.add("String_Node_Str");
  query.setParameter("String_Node_Str","String_Node_Str");
  Store found=(Store)query.getResultList().get(0);
  assertEquals(third,found);
  em2.getTransaction().commit();
  em2.close();
}
Program: 2544
Project: 2544
Buggy source:
@Override public void addField(OpenJPAStateManager stateManager,Mutator<byte[]> mutator,long clock,byte[] key,String cfName,IndexQueue queue){
  Object field=stateManager.fetch(fieldId);
  byte[] orderKey=constructKey(key,orderedMarker);
  byte[] idKey=constructKey(key,idMarker);
  if (field == null) {
    mutator.addDeletion(orderKey,CF_NAME,null,null);
    mutator.addDeletion(idKey,CF_NAME,null,null);
    return;
  }
  writeAdds(stateManager,(Collection<?>)field,mutator,clock,orderKey,idKey,queue);
  writeDeletes(stateManager,(Collection<?>)field,mutator,clock,orderKey,idKey,queue);
  writeChanged(stateManager,(Collection<?>)field,mutator,clock,orderKey,idKey,queue);
}

Fixed version (ground truth):
@Override public void addField(OpenJPAStateManager stateManager,Mutator<byte[]> mutator,long clock,byte[] key,String cfName,IndexQueue queue){
  Object field=stateManager.fetch(fieldId);
  byte[] orderKey=constructKey(key,orderedMarker);
  byte[] idKey=constructKey(key,idMarker);
  if (field == null || ((Collection<?>)field).isEmpty()) {
    mutator.addDeletion(orderKey,CF_NAME,null,null);
    mutator.addDeletion(idKey,CF_NAME,null,null);
    return;
  }
  writeAdds(stateManager,(Collection<?>)field,mutator,clock,orderKey,idKey,queue);
  writeDeletes(stateManager,(Collection<?>)field,mutator,clock,orderKey,idKey,queue);
  writeChanged(stateManager,(Collection<?>)field,mutator,clock,orderKey,idKey,queue);
}
Program: 2545
Project: 2545
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public boolean readField(OpenJPAStateManager stateManager,QueryResult<ColumnSlice<DynamicComposite,byte[]>> result){
  StoreContext context=stateManager.getContext();
  Collection<Object> collection=(Collection<Object>)stateManager.newProxy(fieldId);
  for (  HColumn<DynamicComposite,byte[]> col : result.get().getColumns()) {
    ByteBuffer buff=col.getName().get(0,buffSerializer);
    Object nativeId=elementKeyStrategy.getInstance(buff);
    Object saved=context.find(context.newObjectId(targetClass,nativeId),true,null);
    collection.add(saved);
  }
  stateManager.store(fieldId,collection);
  return result.get().getColumns().size() > 0;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public boolean readField(OpenJPAStateManager stateManager,QueryResult<ColumnSlice<DynamicComposite,byte[]>> result){
  StoreContext context=stateManager.getContext();
  Collection<Object> collection=(Collection<Object>)stateManager.newProxy(fieldId);
  for (  HColumn<DynamicComposite,byte[]> col : result.get().getColumns()) {
    ByteBuffer buff=col.getName().get(0,buffSerializer);
    Object nativeId=elementKeyStrategy.getInstance(buff);
    Object saved=context.find(context.newObjectId(targetClass,nativeId),true,null);
    if (saved == null) {
      logger.warn("String_Node_Str",new Object[]{nativeId,this.fieldName,this.targetClass});
      continue;
    }
    collection.add(saved);
  }
  stateManager.store(fieldId,collection);
  return result.get().getColumns().size() > 0;
}
Program: 2546
Project: 2546
Buggy source:
@Override public void addField(OpenJPAStateManager stateManager,Mutator<byte[]> mutator,long clock,byte[] key,String cfName,IndexQueue queue){
  Object field=stateManager.fetch(fieldId);
  byte[] idKey=constructKey(key,unorderedMarker);
  if (field == null) {
    mutator.addDeletion(idKey,CF_NAME,null,null);
    return;
  }
  writeAdds(stateManager,(Collection<?>)field,mutator,clock,idKey,queue);
  writeDeletes(stateManager,(Collection<?>)field,mutator,clock,idKey,queue);
}

Fixed version (ground truth):
@Override public void addField(OpenJPAStateManager stateManager,Mutator<byte[]> mutator,long clock,byte[] key,String cfName,IndexQueue queue){
  Object field=stateManager.fetch(fieldId);
  byte[] idKey=constructKey(key,unorderedMarker);
  if (field == null || ((Collection<?>)field).isEmpty()) {
    mutator.addDeletion(idKey,CF_NAME,null,null);
    return;
  }
  writeAdds(stateManager,(Collection<?>)field,mutator,clock,idKey,queue);
  writeDeletes(stateManager,(Collection<?>)field,mutator,clock,idKey,queue);
}
Program: 2547
Project: 2547
Buggy source:
/** 
 * Remove all indexes for elements
 * @param ctx
 * @param value
 * @param mutator
 * @param clock
 * @param orderKey
 * @param idKey
 * @param cfName
 */
@SuppressWarnings("String_Node_Str") private void writeDeletes(OpenJPAStateManager stateManager,Collection value,Mutator<byte[]> mutator,long clock,byte[] idKey,IndexQueue queue){
  Collection objects=getRemoved(value);
  if (objects == null) {
    return;
  }
  DynamicComposite idComposite=null;
  ByteBuffer currentId=null;
  StoreContext context=stateManager.getContext();
  OpenJPAStateManager currentSm=null;
  Object oid=null;
  for (  Object current : objects) {
    currentSm=context.getStateManager(current);
    oid=currentSm.fetchObjectId();
    currentId=elementKeyStrategy.toByteBuffer(oid);
    idComposite=newComposite();
    idComposite.addComponent(currentId,buffSerializer);
    mutator.addDeletion(idKey,CF_NAME,idComposite,compositeSerializer,clock);
    DynamicComposite idAudit=new DynamicComposite();
    idAudit.addComponent(currentId,buffSerializer);
    queue.addDelete(new IndexAudit(idKey,idKey,idAudit,clock,CF_NAME,false));
  }
}

Fixed version (ground truth):
/** 
 * Remove all indexes for elements
 * @param ctx
 * @param value
 * @param mutator
 * @param clock
 * @param orderKey
 * @param idKey
 * @param cfName
 */
@SuppressWarnings("String_Node_Str") private void writeDeletes(OpenJPAStateManager stateManager,Collection value,Mutator<byte[]> mutator,long clock,byte[] idKey,IndexQueue queue){
  Collection objects=getRemoved(value);
  if (objects == null) {
    return;
  }
  DynamicComposite idComposite=null;
  ByteBuffer currentId=null;
  StoreContext context=stateManager.getContext();
  OpenJPAStateManager currentSm=null;
  Object oid=null;
  for (  Object current : objects) {
    currentSm=context.getStateManager(current);
    oid=currentSm.fetchObjectId();
    currentId=elementKeyStrategy.toByteBuffer(oid);
    idComposite=newComposite();
    idComposite.addComponent(currentId,buffSerializer,getCassType(buffSerializer));
    mutator.addDeletion(idKey,CF_NAME,idComposite,compositeSerializer,clock);
    DynamicComposite idAudit=new DynamicComposite();
    idAudit.addComponent(currentId,buffSerializer,getCassType(buffSerializer));
    queue.addDelete(new IndexAudit(idKey,idKey,idAudit,clock,CF_NAME,false));
  }
}
Program: 2548
Project: 2548
Buggy source:
/** 
 * Perform all deletions for this index
 * @param audit
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) protected void deleteInternal(IndexAudit audit){
  SliceQuery<byte[],DynamicComposite,byte[]> query=new ThriftSliceQuery(config.getKeyspace(),BytesArraySerializer.get(),compositeSerializer,BytesArraySerializer.get());
  DynamicComposite start=audit.getColumnId();
  DynamicComposite end=new DynamicComposite();
  List<Component<?>> startComponents=start.getComponents();
  Component current;
  int i=0;
  for (; i < startComponents.size() - 1; i++) {
    current=start.getComponent(i);
    end.setComponent(i,current.getValue(),current.getSerializer(),current.getComparator(),ComponentEquality.EQUAL);
  }
  current=start.getComponent(i);
  end.setComponent(i,current.getValue(),current.getSerializer(),current.getComparator(),ComponentEquality.GREATER_THAN_EQUAL);
  ColumnSlice<DynamicComposite,byte[]> slice=null;
  Mutator<byte[]> mutator=createMutator();
  do {
    query.setRange(start,end,false,MAX_COUNT);
    query.setKey(audit.getIdRowKey());
    query.setColumnFamily(audit.getColumnFamily());
    slice=query.execute().get();
    for (    HColumn<DynamicComposite,byte[]> col : slice.getColumns()) {
      deleteColumn(audit,col.getName(),mutator);
      start=col.getName();
    }
  }
 while (slice.getColumns().size() == MAX_COUNT);
  mutator.execute();
}

Fixed version (ground truth):
/** 
 * Perform all deletions for this index
 * @param audit
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) protected void deleteInternal(IndexAudit audit){
  SliceQuery<byte[],DynamicComposite,byte[]> query=new ThriftSliceQuery(config.getKeyspace(),BytesArraySerializer.get(),compositeSerializer,BytesArraySerializer.get());
  DynamicComposite start=audit.getColumnId();
  DynamicComposite end=new DynamicComposite();
  List<Component<?>> startComponents=start.getComponents();
  Component current;
  int i=0;
  for (; i < startComponents.size() - 1; i++) {
    current=start.getComponent(i);
    end.setComponent(i,current.getValue(),current.getSerializer(),current.getComparator(),ComponentEquality.EQUAL);
  }
  current=start.getComponent(i);
  end.setComponent(i,current.getValue(),current.getSerializer(),current.getComparator(),ComponentEquality.GREATER_THAN_EQUAL);
  ColumnSlice<DynamicComposite,byte[]> slice=null;
  HColumn<DynamicComposite,byte[]> maxColumn=null;
  Mutator<byte[]> mutator=createMutator();
  do {
    query.setRange(start,end,false,MAX_COUNT);
    query.setKey(audit.getIdRowKey());
    query.setColumnFamily(audit.getColumnFamily());
    slice=query.execute().get();
    for (    HColumn<DynamicComposite,byte[]> col : slice.getColumns()) {
      deleteColumn(audit,col.getName(),mutator);
      start=col.getName();
    }
  }
 while (slice.getColumns().size() == MAX_COUNT);
  mutator.execute();
}
Program: 2549
Project: 2549
Buggy source:
@Override public byte[] toByteArray(Object oid){
  return dynamicSerializer.toBytes(createComposite(((OpenJPAId)oid).getIdObject()));
}

Fixed version (ground truth):
@Override public byte[] toByteArray(Object oid){
  Object id=((OpenJPAId)oid).getIdObject();
  if (id == null) {
    return null;
  }
  return dynamicSerializer.toBytes(createComposite(id));
}
Program: 2550
Project: 2550
Buggy source:
/** 
 * Get the value as a byte array
 * @param target
 * @return
 */
public byte[] toByteArray(Object oid);

Fixed version (ground truth):
/** 
 * Get the value as a byte array
 * @param target
 * @return The byte array.  Could be null if the oid is null
 */
public byte[] toByteArray(Object oid);
Program: 2551
Project: 2551
Buggy source:
/** 
 * Get the bytes that represent this key.  Can either be a single field or a multi field
 * @param target
 * @return
 */
public ByteBuffer toByteBuffer(Object oid);

Fixed version (ground truth):
/** 
 * Get the bytes that represent this key.  Can either be a single field or a multi field
 * @param target
 * @return The ByteBuffer.  Could be null if the oid is null
 */
public ByteBuffer toByteBuffer(Object oid);
Program: 2552
Project: 2552
Buggy source:
@Override public byte[] toByteArray(Object oid){
  Object id=((OpenJPAId)oid).getIdObject();
  return idSerializer.toBytes(id);
}

Fixed version (ground truth):
@Override public byte[] toByteArray(Object oid){
  Object id=((OpenJPAId)oid).getIdObject();
  if (id == null) {
    return null;
  }
  return idSerializer.toBytes(id);
}
Program: 2553
Project: 2553
Buggy source:
/** 
 * Get the stored entity and it's object id if it exists in the datastore
 * @param stateManager
 * @param keyspace
 * @return
 */
public Class<?> getStoredEntityType(OpenJPAStateManager sm,Keyspace keyspace,MetaCache metaCache){
  Object oid=sm.getObjectId();
  Class<?> oidType=((OpenJPAId)oid).getType();
  if (oidType == null) {
    return null;
  }
  byte[] rowKey=keyStrategy.toByteArray(sm.getObjectId());
  String descrim=strategy.getStoredType(rowKey,columnFamilyName,keyspace);
  if (descrim == null) {
    return null;
  }
  return strategy.getClass(descrim,oidType,metaCache);
}

Fixed version (ground truth):
/** 
 * Get the stored entity and it's object id if it exists in the datastore
 * @param stateManager
 * @param keyspace
 * @return
 */
public Class<?> getStoredEntityType(OpenJPAStateManager sm,Keyspace keyspace,MetaCache metaCache){
  Object oid=sm.getObjectId();
  Class<?> oidType=((OpenJPAId)oid).getType();
  if (oidType == null) {
    return null;
  }
  byte[] rowKey=keyStrategy.toByteArray(oid);
  if (rowKey == null) {
    return null;
  }
  String descrim=strategy.getStoredType(rowKey,columnFamilyName,keyspace);
  if (descrim == null) {
    return null;
  }
  return strategy.getClass(descrim,oidType,metaCache);
}
Program: 2554
Project: 2554
Buggy source:
public IndexDefinition(CassandraClassMetaData metaData,FieldOrder[] indexedFields,IndexOrder[] orderFields){
  this.metaData=metaData;
  this.indexedFields=indexedFields;
  this.orderFields=orderFields;
}

Fixed version (ground truth):
public IndexDefinition(FieldOrder[] indexedFields,IndexOrder[] orderFields){
  this.indexedFields=indexedFields;
  this.orderFields=orderFields;
}
Program: 2555
Project: 2555
Buggy source:
/** 
 * Add a new index definition for the given field with the order expression. This is mostly copied from the default annotation scanner
 * @param orderExpression
 * @param field
 */
public void add(String fieldExpression,String orderExpression,CassandraClassMetaData metaData){
  String[] decs=Strings.split(orderExpression,"String_Node_Str",0);
  IndexOrder[] orders=new IndexOrder[decs.length];
  int spc;
  boolean asc;
  for (int i=0; i < decs.length; i++) {
    decs[i]=decs[i].trim();
    spc=decs[i].indexOf(' ');
    if (spc == -1)     asc=true;
 else {
      asc=decs[i].substring(spc + 1).trim().toLowerCase().startsWith("String_Node_Str");
      decs[i]=decs[i].substring(0,spc);
    }
    orders[i]=new IndexOrder(decs[i],asc);
    FieldMetaData fmd=metaData.getDeclaredField(decs[i]);
    if (fmd != null)     fmd.setUsedInOrderBy(true);
  }
  decs=Strings.split(fieldExpression,"String_Node_Str",0);
  FieldOrder[] fields=new FieldOrder[decs.length];
  for (int i=0; i < fields.length; i++) {
    decs[i]=decs[i].trim();
    spc=decs[i].indexOf(' ');
    if (spc == -1)     asc=true;
 else {
      asc=decs[i].substring(spc + 1).trim().toLowerCase().startsWith("String_Node_Str");
      decs[i]=decs[i].substring(0,spc);
    }
    fields[i]=new FieldOrder(decs[i],asc);
  }
  IndexDefinition indexDef=new IndexDefinition(metaData,fields,orders);
  indexDefs.add(indexDef);
}

Fixed version (ground truth):
/** 
 * Add a new index definition for the given field with the order expression. This is mostly copied from the default annotation scanner
 * @param orderExpression
 * @param field
 */
public void add(String fieldExpression,String orderExpression,CassandraClassMetaData metaData){
  String[] decs=Strings.split(orderExpression,"String_Node_Str",0);
  IndexOrder[] orders=new IndexOrder[decs.length];
  int spc;
  boolean asc;
  for (int i=0; i < decs.length; i++) {
    decs[i]=decs[i].trim();
    spc=decs[i].indexOf(' ');
    if (spc == -1)     asc=true;
 else {
      asc=decs[i].substring(spc + 1).trim().toLowerCase().startsWith("String_Node_Str");
      decs[i]=decs[i].substring(0,spc);
    }
    orders[i]=new IndexOrder(decs[i],asc);
    FieldMetaData fmd=metaData.getDeclaredField(decs[i]);
    if (fmd != null)     fmd.setUsedInOrderBy(true);
  }
  decs=Strings.split(fieldExpression,"String_Node_Str",0);
  FieldOrder[] fields=new FieldOrder[decs.length];
  for (int i=0; i < fields.length; i++) {
    decs[i]=decs[i].trim();
    spc=decs[i].indexOf(' ');
    if (spc == -1)     asc=true;
 else {
      asc=decs[i].substring(spc + 1).trim().toLowerCase().startsWith("String_Node_Str");
      decs[i]=decs[i].substring(0,spc);
    }
    fields[i]=new FieldOrder(decs[i],asc);
  }
  IndexDefinition indexDef=new IndexDefinition(fields,orders);
  indexDefs.add(indexDef);
}
Program: 2556
Project: 2556
Buggy source:
@Override public boolean initialize(OpenJPAStateManager stateManager,PCState pcState,FetchConfiguration fetchConfiguration,Object obj){
  Class<?> type=cassandraStore.getDataStoreId(stateManager.getId(),this.getContext());
  if (type == null) {
    return false;
  }
  log.debug("String_Node_Str");
  stateManager.initialize(type,pcState);
  stateManager.load(fetchConfiguration);
  return true;
}

Fixed version (ground truth):
@Override public boolean initialize(OpenJPAStateManager stateManager,PCState pcState,FetchConfiguration fetchConfiguration,Object obj){
  Class<?> type=cassandraStore.getDataStoreId(stateManager.getId(),this.getContext());
  if (type == null) {
    return false;
  }
  Class<?> requestedType=((OpenJPAId)stateManager.getId()).getType();
  if (!requestedType.isAssignableFrom(type)) {
    return false;
  }
  log.debug("String_Node_Str");
  stateManager.initialize(type,pcState);
  stateManager.load(fetchConfiguration);
  return true;
}
Program: 2557
Project: 2557
Buggy source:
/** 
 * Find the persisted class in cassandra. If this is not a subclass, the oid is always returned
 * @param oid
 * @return
 */
public Class<?> getDataStoreId(Object oid,StoreContext ctx){
  Class<?> requested=((OpenJPAId)oid).getType();
  ClassMetaData metaData=ctx.getConfiguration().getMetaDataRepositoryInstance().getMetaData(requested,ctx.getClassLoader(),true);
  EntityFacade entityFacade=conf.getMetaCache().getFacade(metaData,conf.getSerializer());
  return entityFacade.getStoredEntityType(oid,keyspace,conf.getMetaCache());
}

Fixed version (ground truth):
/** 
 * Find the persisted class in cassandra. If this is not a subclass, the oid is always returned
 * @param oid
 * @return
 */
public Class<?> getDataStoreId(Object oid,StoreContext ctx){
  if (((OpenJPAId)oid).getIdObject() == null) {
    return null;
  }
  Class<?> requested=((OpenJPAId)oid).getType();
  ClassMetaData metaData=ctx.getConfiguration().getMetaDataRepositoryInstance().getMetaData(requested,ctx.getClassLoader(),true);
  EntityFacade entityFacade=conf.getMetaCache().getFacade(metaData,conf.getSerializer());
  return entityFacade.getStoredEntityType(oid,keyspace,conf.getMetaCache());
}
Program: 2558
Project: 2558
Buggy source:
@Override public boolean initialize(OpenJPAStateManager stateManager,PCState pcState,FetchConfiguration fetchConfiguration,Object obj){
  Class<?> type=stateManager.getMetaData().getDescribedType();
  if (Modifier.isAbstract(type.getModifiers())) {
    return false;
  }
  log.debug("String_Node_Str");
  stateManager.initialize(type,pcState);
  return cassandraStore.getObject(stateManager,stateManager.getUnloaded(fetchConfiguration));
}

Fixed version (ground truth):
@Override public boolean initialize(OpenJPAStateManager stateManager,PCState pcState,FetchConfiguration fetchConfiguration,Object obj){
  Class<?> type=cassandraStore.getDataStoreId(stateManager.getId(),this.getContext());
  if (type == null) {
    return false;
  }
  log.debug("String_Node_Str");
  stateManager.initialize(type,pcState);
  stateManager.load(fetchConfiguration);
  return true;
}
Program: 2560
Project: 2560
Buggy source:
public AsyncInMemoryIndexingService(CassandraStoreConfiguration conf){
  Thread audit=new Thread(new AuditThread());
  audit.setDaemon(true);
  audit.start();
  Thread delete=new Thread(new DeleteThread());
  delete.setDaemon(true);
  delete.start();
}

Fixed version (ground truth):
public AsyncInMemoryIndexingService(){
  Thread audit=new Thread(new AuditThread());
  audit.setDaemon(true);
  audit.start();
  Thread delete=new Thread(new DeleteThread());
  delete.setDaemon(true);
  delete.start();
}
Program: 2561
Project: 2561
Buggy source:
/** 
 * Create an instance of the object set from the given prop key. If one is not preset, defaultClass will be used
 * @param propKey
 * @param defaultClass
 * @return
 */
private Object createInstance(String propKey,String defaultClass){
  String className=getValue(propKey).getOriginalValue();
  if (className == null) {
    className=defaultClass;
  }
  try {
    Class<?> clazz=Class.forName(className);
    return clazz.newInstance();
  }
 catch (  Exception e) {
    throw new UserException(String.format("String_Node_Str",className,EmbeddedSerializer.class),e);
  }
}

Fixed version (ground truth):
/** 
 * Create an instance of the object set from the given prop key. If one is not preset, defaultClass will be used
 * @param propKey
 * @param defaultClass
 * @return
 * @throws ClassNotFoundException
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
private Object createInstance(String className,String defaultClass) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
  if (className == null) {
    className=defaultClass;
  }
  Class<?> clazz=Class.forName(className);
  return clazz.newInstance();
}
Program: 2562
Project: 2562
Buggy source:
/** 
 * Get the serializer configured
 * @return
 */
public EmbeddedSerializer getSerializer(){
  if (serializer != null) {
    return serializer;
  }
  serializer=(EmbeddedSerializer)createInstance(SERIALIZER_PROP,JavaSerializer.class.getName());
  return serializer;
}

Fixed version (ground truth):
/** 
 * Get the serializer configured
 * @return
 */
public EmbeddedSerializer getSerializer(){
  if (serializer != null) {
    return serializer;
  }
  String className=getValue(SERIALIZER_PROP).getOriginalValue();
  try {
    serializer=(EmbeddedSerializer)createInstance(className,JavaSerializer.class.getName());
  }
 catch (  Exception e) {
    throw new UserException(String.format("String_Node_Str",className,EmbeddedSerializer.class),e);
  }
  return serializer;
}
Program: 2563
Project: 2563
Buggy source:
/** 
 * @return the indexingService
 */
public IndexingService getIndexingService(){
  if (indexingService != null) {
    return indexingService;
  }
  this.indexingService=(IndexingService)createInstance(INDEXING_PROP,SyncInMemoryIndexingService.class.getName());
  this.indexingService.postCreate(this);
  return this.indexingService;
}

Fixed version (ground truth):
/** 
 * @return the indexingService
 */
public IndexingService getIndexingService(){
  if (indexingService != null) {
    return indexingService;
  }
  String className=getValue(INDEXING_PROP).getString();
  try {
    this.indexingService=(IndexingService)createInstance(className,SyncInMemoryIndexingService.class.getName());
  }
 catch (  Exception e) {
    throw new UserException(String.format("String_Node_Str",className,IndexingService.class),e);
  }
  this.indexingService.postCreate(this);
  return this.indexingService;
}
Program: 2565
Project: 2565
Buggy source:
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (!(obj instanceof IndexDefinition))   return false;
  IndexDefinition other=(IndexDefinition)obj;
  if (!Arrays.equals(indexedFields,other.indexedFields))   return false;
  if (!Arrays.equals(orderFields,other.orderFields))   return false;
  return true;
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (!(obj instanceof IndexDefinition))   return false;
  IndexDefinition other=(IndexDefinition)obj;
  if (!Arrays.equals(orderFields,other.orderFields))   return false;
  if (indexedFields.length != other.indexedFields.length) {
    return false;
  }
  int matchCount=0;
  for (int i=0; i < indexedFields.length; i++) {
    for (int j=0; j < other.indexedFields.length; j++) {
      if (indexedFields[i].equals(other.indexedFields[i])) {
        matchCount++;
        continue;
      }
    }
  }
  return matchCount == indexedFields.length;
}
Program: 2566
Project: 2566
Buggy source:
/** 
 * Compare 2 index definitions. Index definitions are compared in the following way If an order is defined, then all order fields must be preset and in the same order for order comparison to == 0 If these orders are not the same, the shortest number of order operands is returned as less. If the order operands are the same, the fields are compared. The fields follow the same logic of operands Indexes with less fields are returned with < 0 to encourage the use of shorter rows for faster querying Not a null safe comparator
 * @author Todd Nine
 */
@Override public int compareTo(IndexDefinition def2){
  int compare=0;
  IndexOrder[] def2Order=def2.getOrderFields();
  if (orderFields.length > def2Order.length) {
    return 1;
  }
 else   if (orderFields.length < def2Order.length) {
    return -1;
  }
  for (int i=0; i < orderFields.length; i++) {
    compare=orderFields[i].getName().compareTo(def2Order[i].getName());
    if (compare != 0) {
      return compare;
    }
  }
  FieldOrder[] def2Field=def2.getIndexedFields();
  if (indexedFields.length > def2Field.length) {
    return 1;
  }
 else   if (indexedFields.length < def2Field.length) {
    return -1;
  }
  for (int i=0; i < indexedFields.length; i++) {
    compare=indexedFields[i].compareTo(def2Field[i]);
    if (compare != 0) {
      return compare;
    }
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * Compare 2 index definitions. Index definitions are compared in the following way If an order is defined, then all order fields must be preset and in the same order for order comparison to == 0 If these orders are not the same, the shortest number of order operands is returned as less. If the order operands are the same, the fields are compared. The fields follow the same logic of operands Indexes with less fields are returned with < 0 to encourage the use of shorter rows for faster querying Not a null safe comparator
 * @author Todd Nine
 */
@Override public int compareTo(IndexDefinition def2){
  int compare=0;
  IndexOrder[] def2Order=def2.getOrderFields();
  if (orderFields.length > def2Order.length) {
    return 1;
  }
 else   if (orderFields.length < def2Order.length) {
    return -1;
  }
  for (int i=0; i < orderFields.length; i++) {
    compare=orderFields[i].getName().compareTo(def2Order[i].getName());
    if (compare != 0) {
      return compare;
    }
  }
  FieldOrder[] def2Field=def2.getIndexedFields();
  if (indexedFields.length > def2Field.length) {
    return 1;
  }
 else   if (indexedFields.length < def2Field.length) {
    return -1;
  }
  int matchCount=0;
  for (int i=0; i < indexedFields.length; i++) {
    for (int j=0; j < def2Field.length; j++) {
      if (indexedFields[i].getName().equals(def2Field[j].getName())) {
        matchCount++;
        break;
      }
    }
  }
  return matchCount - indexedFields.length;
}
Program: 2567
Project: 2567
Buggy source:
@Override public boolean initialize(OpenJPAStateManager stateManager,PCState pcState,FetchConfiguration fetchConfiguration,Object obj){
  log.debug("String_Node_Str");
  stateManager.initialize(stateManager.getMetaData().getDescribedType(),pcState);
  return cassandraStore.getObject(stateManager,stateManager.getUnloaded(fetchConfiguration));
}

Fixed version (ground truth):
@Override public boolean initialize(OpenJPAStateManager stateManager,PCState pcState,FetchConfiguration fetchConfiguration,Object obj){
  Class<?> type=stateManager.getMetaData().getDescribedType();
  if (Modifier.isAbstract(type.getModifiers())) {
    return false;
  }
  log.debug("String_Node_Str");
  stateManager.initialize(type,pcState);
  return cassandraStore.getObject(stateManager,stateManager.getUnloaded(fetchConfiguration));
}
Program: 2568
Project: 2568
Buggy source:
/** 
 * Read the field and load all ids found
 * @param stateManager
 * @param result
 */
public void readField(OpenJPAStateManager stateManager,QueryResult<ColumnSlice<DynamicComposite,byte[]>> result){
  Object[] fields=null;
  StoreContext context=stateManager.getContext();
  Collection<Object> collection=(Collection<Object>)stateManager.newProxy(fieldId);
  DynamicComposite dynamicCol=null;
  for (  HColumn<DynamicComposite,byte[]> col : result.get().getColumns()) {
    Object nativeId=col.getName().get(compositeFieldLength - 1,this.idSerizlizer);
    collection.add(context.find(context.newObjectId(targetClass,nativeId),true,null));
  }
  stateManager.storeObject(fieldId,collection);
}

Fixed version (ground truth):
/** 
 * Read the field and load all ids found
 * @param stateManager
 * @param result
 */
public void readField(OpenJPAStateManager stateManager,QueryResult<ColumnSlice<DynamicComposite,byte[]>> result){
  Object[] fields=null;
  StoreContext context=stateManager.getContext();
  Collection<Object> collection=(Collection<Object>)stateManager.newProxy(fieldId);
  DynamicComposite dynamicCol=null;
  for (  HColumn<DynamicComposite,byte[]> col : result.get().getColumns()) {
    Object nativeId=col.getName().get(compositeFieldLength - 1,this.idSerizlizer);
    Object oid=context.newObjectId(targetClass,nativeId);
    Object found=context.find(oid,true,null);
    if (found == null) {
      continue;
    }
    collection.add(found);
  }
  stateManager.storeObject(fieldId,collection);
}
Program: 2569
Project: 2569
Buggy source:
@Override public void readField(OpenJPAStateManager stateManager,QueryResult<ColumnSlice<DynamicComposite,byte[]>> result){
  Object[] fields=null;
  StoreContext context=stateManager.getContext();
  Collection<Object> collection=(Collection<Object>)stateManager.newProxy(fieldId);
  DynamicComposite dynamicCol=null;
  for (  HColumn<DynamicComposite,byte[]> col : result.get().getColumns()) {
    Object nativeId=col.getName().get(0,this.idSerizlizer);
    collection.add(context.find(context.newObjectId(targetClass,nativeId),true,null));
  }
  stateManager.storeObject(fieldId,collection);
}

Fixed version (ground truth):
@Override public void readField(OpenJPAStateManager stateManager,QueryResult<ColumnSlice<DynamicComposite,byte[]>> result){
  Object[] fields=null;
  StoreContext context=stateManager.getContext();
  Collection<Object> collection=(Collection<Object>)stateManager.newProxy(fieldId);
  DynamicComposite dynamicCol=null;
  for (  HColumn<DynamicComposite,byte[]> col : result.get().getColumns()) {
    Object nativeId=col.getName().get(0,this.idSerizlizer);
    Object saved=context.find(context.newObjectId(targetClass,nativeId),true,null);
    collection.add(saved);
  }
  stateManager.storeObject(fieldId,collection);
}
Program: 2570
Project: 2570
Buggy source:
@Override public boolean isCached(List<Object> arg0,BitSet arg1){
  log.debug("String_Node_Str");
  return false;
}

Fixed version (ground truth):
@Override public boolean isCached(List<Object> oids,BitSet edata){
  log.debug("String_Node_Str");
  return false;
}
Program: 2571
Project: 2571
Buggy source:
@Override public boolean load(OpenJPAStateManager stateManager,BitSet fields,FetchConfiguration arg2,int arg3,Object arg4){
  log.debug("String_Node_Str");
  return cassandraStore.getObject(stateManager,fields);
}

Fixed version (ground truth):
@Override public boolean load(OpenJPAStateManager stateManager,BitSet fields,FetchConfiguration fetch,int lockLevel,Object edata){
  log.debug("String_Node_Str");
  return cassandraStore.getObject(stateManager,fields);
}
Program: 2572
Project: 2572
Buggy source:
@Override public boolean exists(OpenJPAStateManager arg0,Object arg1){
  log.debug("String_Node_Str");
  return false;
}

Fixed version (ground truth):
@Override public boolean exists(OpenJPAStateManager stateManager,Object edata){
  log.debug("String_Node_Str");
  return cassandraStore.exists(stateManager);
}
Program: 2573
Project: 2573
Buggy source:
@Override public boolean initialize(OpenJPAStateManager stateManager,PCState pcState,FetchConfiguration fetchConfiguration,Object obj){
  log.debug("String_Node_Str");
  cassandraStore.open();
  stateManager.initialize(stateManager.getMetaData().getDescribedType(),pcState);
  cassandraStore.getObject(stateManager,stateManager.getUnloaded(fetchConfiguration));
  return true;
}

Fixed version (ground truth):
@Override public boolean initialize(OpenJPAStateManager stateManager,PCState pcState,FetchConfiguration fetchConfiguration,Object obj){
  log.debug("String_Node_Str");
  cassandraStore.open();
  stateManager.initialize(stateManager.getMetaData().getDescribedType(),pcState);
  return cassandraStore.getObject(stateManager,stateManager.getUnloaded(fetchConfiguration));
}
Program: 2575
Project: 2575
Buggy source:
/** 
 * Create columns and add them to the collection of columns.
 * @param stateManager
 * @param objects
 * @param orders
 * @param clock
 */
private void createColumns(OpenJPAStateManager stateManager,Collection<?> objects,Set<HColumn<Composite,byte[]>> orders,Set<HColumn<Composite,byte[]>> keys,long clock){
  StoreContext ctx=stateManager.getContext();
  Composite orderComposite=null;
  Composite idComposite=null;
  for (  Object current : objects) {
    Object currentId=mappingUtils.getTargetObject(ctx.getObjectId(current));
    idComposite=new Composite();
    orderComposite=new Composite();
    idComposite.add(currentId);
    for (    OrderField order : orderBy) {
      order.addField(idComposite,current);
      order.addField(orderComposite,current);
    }
    orderComposite.add(currentId);
    orders.add(new HColumnImpl<Composite,byte[]>(orderComposite,HOLDER,clock,compositeSerializer,BytesArraySerializer.get()));
    keys.add(new HColumnImpl<Composite,byte[]>(idComposite,HOLDER,clock,compositeSerializer,BytesArraySerializer.get()));
  }
}

Fixed version (ground truth):
/** 
 * Create columns and add them to the collection of columns.
 * @param stateManager
 * @param objects
 * @param orders
 * @param clock
 */
private void createColumns(OpenJPAStateManager stateManager,Collection<?> objects,Set<HColumn<Composite,byte[]>> orders,Set<HColumn<Composite,byte[]>> keys,long clock){
  StoreContext ctx=stateManager.getContext();
  Composite orderComposite=null;
  Composite idComposite=null;
  for (  Object current : objects) {
    Object currentId=mappingUtils.getTargetObject(ctx.getObjectId(current));
    idComposite=new Composite();
    orderComposite=new Composite();
    idComposite.add(currentId);
    for (    OrderField order : orderBy) {
      order.addField(stateManager,idComposite,current);
      order.addField(stateManager,orderComposite,current);
    }
    orderComposite.add(currentId);
    orders.add(new HColumnImpl<Composite,byte[]>(orderComposite,HOLDER,clock,compositeSerializer,BytesArraySerializer.get()));
    keys.add(new HColumnImpl<Composite,byte[]>(idComposite,HOLDER,clock,compositeSerializer,BytesArraySerializer.get()));
  }
}
Program: 2576
Project: 2576
Buggy source:
/** 
 * Add the field this order represents to the composite
 * @param composite
 * @param instance
 */
protected void addField(Composite composite,Object instance){
  if (instance == null) {
    return;
  }
  if (!(instance instanceof PersistenceCapable)) {
    throw new MetaDataException(String.format("String_Node_Str",instance.getClass(),PersistenceCapable.class));
  }
  OpenJPAStateManager stateManager=(OpenJPAStateManager)((PersistenceCapable)instance).pcGetStateManager();
  if (stateManager == null) {
    throw new UserException(String.format("String_Node_Str",targetFieldName,instance));
  }
  Object value=stateManager.fetch(targetFieldIndex);
  composite.add(value);
}

Fixed version (ground truth):
/** 
 * Add the field this order represents to the composite
 * @param composite
 * @param instance
 */
protected void addField(OpenJPAStateManager manager,Composite composite,Object instance){
  if (instance == null) {
    return;
  }
  OpenJPAStateManager stateManager=manager.getContext().getStateManager(instance);
  if (stateManager == null) {
    throw new UserException(String.format("String_Node_Str",targetFieldName,instance));
  }
  Object value=stateManager.fetch(targetFieldIndex);
  composite.add(value);
}
Program: 2577
Project: 2577
Buggy source:
public static ChatConfig getFromMeta(){
  ChatConfig config=new ChatConfig();
  String chatURI=PageAssist.getMeta("String_Node_Str");
  config.openChat=XmppURI.uri(chatURI);
  config.sendButtonVisible=PageAssist.isMetaTrue("String_Node_Str");
  return config;
}

Fixed version (ground truth):
public static ChatConfig getFromMeta(){
  ChatConfig config=new ChatConfig();
  String chatURI=PageAssist.getMeta("String_Node_Str");
  config.openChat=XmppURI.uri(chatURI);
  config.sendButtonVisible=PageAssist.isMetaTrue("String_Node_Str");
  config.enableEmoticons=PageAssist.isMetaTrue("String_Node_Str");
  return config;
}
Program: 2578
Project: 2578
Buggy source:
public HablarChat(final Hablar hablar,final ChatConfig chatConfig,final XmppRoster roster,final ChatManager chatManager,final StateManager stateManager){
  new HablarChatManager(roster,chatManager,hablar,chatConfig);
  hablar.addPageAddedHandler(new PageAddedHandler(){
    @Override public void onPageAdded(    final PageAddedEvent event){
      if (event.isType(PairChatPresenter.TYPE)) {
        final PairChatPage page=(PairChatPage)event.getPage();
        new HablarChatStateManager(stateManager,page);
      }
    }
  }
,true);
}

Fixed version (ground truth):
public HablarChat(final Hablar hablar,final ChatConfig chatConfig,final XmppRoster roster,final ChatManager chatManager,final StateManager stateManager){
  ChatMessageFormatter.addReplacements(new StandardChatMessageFormatReplacements());
  if (chatConfig.enableEmoticons) {
    ChatMessageFormatter.addReplacements(new EmoticonsChatMessageFormatReplacements());
  }
  new HablarChatManager(roster,chatManager,hablar,chatConfig);
  hablar.addPageAddedHandler(new PageAddedHandler(){
    @Override public void onPageAdded(    final PageAddedEvent event){
      if (event.isType(PairChatPresenter.TYPE)) {
        final PairChatPage page=(PairChatPage)event.getPage();
        new HablarChatStateManager(stateManager,page);
      }
    }
  }
,true);
}