nus-yam/ex-repair huggingface dataset:
Program: 97996
Project: 97996
Buggy source:
public synchronized static DiskAccessOneFile getSession(Node node,AbstractCache cache){
  String dbPath=node.getDbPath();
  LOGGER.info("String_Node_Str",dbPath);
  Path path=FileSystems.getDefault().getPath(dbPath);
  SessionManager sm=null;
  try {
    for (    SessionManager smi : sessions) {
      if (Files.isSameFile(smi.getPath(),path)) {
        sm=smi;
        break;
      }
    }
  }
 catch (  IOException e) {
    throw DBLogger.newFatal("String_Node_Str" + dbPath,e);
  }
  if (sm == null) {
    sm=new SessionManager(path);
    sessions.add(sm);
  }
 else {
    MULTIPLE_SESSIONS_ARE_OPEN=true;
    if (FAIL_BECAUSE_OF_ACTIVE_NON_TX_READ) {
      throw DBLogger.newFatal("String_Node_Str" + "String_Node_Str");
    }
  }
  return sm.createSession(node,cache);
}

Fixed version (ground truth):
public static DiskAccessOneFile getSession(Node node,AbstractCache cache){
  String dbPath=node.getDbPath();
  LOGGER.info("String_Node_Str",dbPath);
  Path path=FileSystems.getDefault().getPath(dbPath);
  SessionManager sm=null;
synchronized (sessions) {
    try {
      for (      SessionManager smi : sessions) {
        if (Files.isSameFile(smi.getPath(),path)) {
          sm=smi;
          break;
        }
      }
    }
 catch (    IOException e) {
      throw DBLogger.newFatal("String_Node_Str" + dbPath,e);
    }
    if (sm == null) {
      sm=new SessionManager(path);
      sessions.add(sm);
    }
 else {
      MULTIPLE_SESSIONS_ARE_OPEN=true;
      if (FAIL_BECAUSE_OF_ACTIVE_NON_TX_READ) {
        throw DBLogger.newFatal("String_Node_Str" + "String_Node_Str");
      }
    }
  }
  return sm.createSession(node,cache);
}
Program: 97997
Project: 97997
Buggy source:
private FNCT_OP parseFunctionName(QueryFunction baseObjectFn){
  Class<?> baseType=baseObjectFn.getReturnType();
  Token t=token();
  if (String.class == baseType) {
switch (t.str) {
case "String_Node_Str":
      return FNCT_OP.STR_contains_NON_JDO;
case "String_Node_Str":
    return FNCT_OP.STR_matches;
case "String_Node_Str":
  return FNCT_OP.STR_startsWith;
case "String_Node_Str":
return FNCT_OP.STR_endsWith;
}
}
if (Map.class.isAssignableFrom(baseType)) {
switch (t.str) {
case "String_Node_Str":
return FNCT_OP.MAP_containsKey;
case "String_Node_Str":
return FNCT_OP.MAP_containsValue;
case "String_Node_Str":
return FNCT_OP.MAP_isEmpty;
case "String_Node_Str":
return FNCT_OP.MAP_size;
case "String_Node_Str":
return FNCT_OP.MAP_get;
}
}
if (List.class.isAssignableFrom(baseType)) {
switch (t.str) {
case "String_Node_Str":
return FNCT_OP.LIST_get;
}
}
if (Collection.class.isAssignableFrom(baseType)) {
switch (t.str) {
case "String_Node_Str":
return FNCT_OP.COLL_contains;
case "String_Node_Str":
return FNCT_OP.COLL_isEmpty;
case "String_Node_Str":
return FNCT_OP.COLL_size;
}
}
return null;
}

Fixed version (ground truth):
private FNCT_OP parseFunctionName(QueryFunction baseObjectFn){
  Class<?> baseType=baseObjectFn.getReturnType();
  if (baseType == null) {
    return null;
  }
  Token t=token();
  if (String.class == baseType) {
switch (t.str) {
case "String_Node_Str":
      return FNCT_OP.STR_contains_NON_JDO;
case "String_Node_Str":
    return FNCT_OP.STR_matches;
case "String_Node_Str":
  return FNCT_OP.STR_startsWith;
case "String_Node_Str":
return FNCT_OP.STR_endsWith;
}
}
if (Map.class.isAssignableFrom(baseType)) {
switch (t.str) {
case "String_Node_Str":
return FNCT_OP.MAP_containsKey;
case "String_Node_Str":
return FNCT_OP.MAP_containsValue;
case "String_Node_Str":
return FNCT_OP.MAP_isEmpty;
case "String_Node_Str":
return FNCT_OP.MAP_size;
case "String_Node_Str":
return FNCT_OP.MAP_get;
}
}
if (List.class.isAssignableFrom(baseType)) {
switch (t.str) {
case "String_Node_Str":
return FNCT_OP.LIST_get;
}
}
if (Collection.class.isAssignableFrom(baseType)) {
switch (t.str) {
case "String_Node_Str":
return FNCT_OP.COLL_contains;
case "String_Node_Str":
return FNCT_OP.COLL_isEmpty;
case "String_Node_Str":
return FNCT_OP.COLL_size;
}
}
return null;
}
Program: 97998
Project: 97998
Buggy source:
public QueryTreeNode parseQuery(){
  tokens=tokenize(str);
  if (match(T_TYPE.SELECT)) {
    tInc();
  }
  if (match(T_TYPE.UNIQUE)) {
    tInc();
  }
  if (match(T_TYPE.FROM)) {
    tInc();
    if (!clsDef.getClassName().equals(token().str)) {
      throw DBLogger.newUser("String_Node_Str" + token().pos + "String_Node_Str"+ clsDef);
    }
    tInc();
  }
  if (match(T_TYPE.WHERE)) {
    tInc();
  }
  boolean negate=false;
  QueryTreeNode qn=parseTree(negate);
  while (hasMoreTokens()) {
    qn=parseTree(null,qn,negate);
  }
  return qn;
}

Fixed version (ground truth):
public QueryTreeNode parseQuery(){
  try {
    tokens=tokenize(str);
    if (match(T_TYPE.SELECT)) {
      tInc();
    }
    if (match(T_TYPE.UNIQUE)) {
      tInc();
    }
    if (match(T_TYPE.FROM)) {
      tInc();
      if (!clsDef.getClassName().equals(token().str)) {
        throw DBLogger.newUser("String_Node_Str" + token().pos + "String_Node_Str"+ clsDef);
      }
      tInc();
    }
    if (match(T_TYPE.WHERE)) {
      tInc();
    }
    boolean negate=false;
    QueryTreeNode qn=parseTree(negate);
    while (hasMoreTokens()) {
      qn=parseTree(null,qn,negate);
    }
    return qn;
  }
 catch (  StringIndexOutOfBoundsException e) {
    throw DBLogger.newUser("String_Node_Str" + pos + "String_Node_Str"+ str);
  }
}
Program: 97999
Project: 97999
Buggy source:
private Token token(int i){
  return tokens.get(tPos + i);
}

Fixed version (ground truth):
private Token token(int i){
  try {
    return tokens.get(tPos + i);
  }
 catch (  IndexOutOfBoundsException e) {
    throw DBLogger.newUser("String_Node_Str" + tokens.get(tokens.size() - 1).pos + "String_Node_Str"+ str);
  }
}
Program: 98000
Project: 98000
Buggy source:
private Object tokenToNumber(){
  Token t=token();
  String nStr=token().str;
  int base=10;
  if (nStr.contains("String_Node_Str")) {
    base=16;
    nStr=nStr.substring(2);
  }
 else   if (nStr.contains("String_Node_Str")) {
    base=2;
    nStr=nStr.substring(2);
  }
  int len=nStr.length();
  if (nStr.equals("String_Node_Str")) {
    return Double.NaN;
  }
  if (nStr.equals("String_Node_Str")) {
    return Double.POSITIVE_INFINITY;
  }
  if (t.type == T_TYPE.NUMBER_DOUBLE || t.type == T_TYPE.NUMBER_FLOAT) {
    try {
      if (t.type == T_TYPE.NUMBER_FLOAT) {
        return Float.parseFloat(nStr.substring(0,len - 1));
      }
      return Double.parseDouble(nStr);
    }
 catch (    NumberFormatException e) {
      return new BigDecimal(nStr);
    }
  }
  if (t.type == T_TYPE.NUMBER_INT || t.type == T_TYPE.NUMBER_LONG) {
    try {
      if (t.type == T_TYPE.NUMBER_INT) {
        return Integer.parseInt(nStr,base);
      }
      return Long.parseLong(nStr.substring(0,len - 1),base);
    }
 catch (    NumberFormatException e) {
      return new BigInteger(nStr);
    }
  }
  throw new IllegalArgumentException(token().type.name());
}

Fixed version (ground truth):
private Object tokenToNumber(){
  Token t=token();
  String nStr=token().str;
  int base=10;
  if (nStr.contains("String_Node_Str")) {
    base=16;
    nStr=nStr.substring(2);
  }
 else   if (nStr.contains("String_Node_Str")) {
    base=2;
    nStr=nStr.substring(2);
  }
  int len=nStr.length();
  if (nStr.equals("String_Node_Str")) {
    return Double.NaN;
  }
  if (nStr.equals("String_Node_Str")) {
    return Double.POSITIVE_INFINITY;
  }
  if (t.type == T_TYPE.NUMBER_DOUBLE || t.type == T_TYPE.NUMBER_FLOAT) {
    try {
      if (t.type == T_TYPE.NUMBER_FLOAT) {
        return Float.parseFloat(nStr.substring(0,len - 1));
      }
      return Double.parseDouble(nStr);
    }
 catch (    NumberFormatException e) {
      return new BigDecimal(nStr);
    }
  }
  if (t.type == T_TYPE.NUMBER_INT || t.type == T_TYPE.NUMBER_LONG) {
    try {
      if (t.type == T_TYPE.NUMBER_INT) {
        return Integer.parseInt(nStr,base);
      }
      return Long.parseLong(nStr.substring(0,len - 1),base);
    }
 catch (    NumberFormatException e) {
      try {
        return new BigInteger(nStr,base);
      }
 catch (      NumberFormatException e2) {
        throw DBLogger.newUser("String_Node_Str" + t.str);
      }
    }
  }
  throw new IllegalArgumentException(token().type.name());
}
Program: 98002
Project: 98002
Buggy source:
public static COMPARISON_TYPE fromOperands(COMPARISON_TYPE lhsCt,COMPARISON_TYPE rhsCt){
  if (rhsCt.ordinal() < lhsCt.ordinal()) {
    COMPARISON_TYPE x=lhsCt;
    lhsCt=rhsCt;
    rhsCt=x;
  }
  if (lhsCt == SCO || rhsCt == SCO) {
    return SCO;
  }
  if (lhsCt == BIG_DECIMAL) {
    if (rhsCt.canBeNumber()) {
      return BIG_DECIMAL;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == BIG_INT) {
    if (rhsCt.canBeNumber()) {
      return BIG_INT;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == DOUBLE) {
    if (rhsCt.canBeNumber()) {
      return DOUBLE;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == FLOAT) {
    if (rhsCt.canBeNumber()) {
      return FLOAT;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == LONG) {
    if (rhsCt.canBeNumber()) {
      return LONG;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == INT) {
    if (rhsCt.canBeNumber()) {
      return INT;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == SHORT) {
    if (rhsCt.canBeNumber()) {
      return SHORT;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == BYTE) {
    if (rhsCt.canBeNumber()) {
      return BYTE;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == CHAR) {
    if (rhsCt.canBeNumber()) {
      return CHAR;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == BOOLEAN && rhsCt == BOOLEAN) {
    return BOOLEAN;
  }
  if (lhsCt == PC && rhsCt == PC) {
    return PC;
  }
  if (lhsCt == STRING && rhsCt == STRING) {
    return STRING;
  }
  return UNKNOWN;
}

Fixed version (ground truth):
public static COMPARISON_TYPE fromOperands(COMPARISON_TYPE lhsCt,COMPARISON_TYPE rhsCt){
  if (rhsCt.ordinal() < lhsCt.ordinal()) {
    COMPARISON_TYPE x=lhsCt;
    lhsCt=rhsCt;
    rhsCt=x;
  }
  if (lhsCt == SCO || rhsCt == SCO) {
    return SCO;
  }
  if (lhsCt == BIG_DECIMAL) {
    if (rhsCt.canBeNumber()) {
      return BIG_DECIMAL;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == BIG_INT) {
    if (rhsCt.canBeNumber()) {
      return BIG_INT;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == DOUBLE) {
    if (rhsCt.canBeNumber()) {
      return DOUBLE;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == FLOAT) {
    if (rhsCt.canBeNumber()) {
      return FLOAT;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == LONG) {
    if (rhsCt.canBeNumber()) {
      return LONG;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == INT) {
    if (rhsCt.canBeNumber()) {
      return INT;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == SHORT) {
    if (rhsCt.canBeNumber()) {
      return SHORT;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == BYTE) {
    if (rhsCt.canBeNumber()) {
      return BYTE;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == CHAR) {
    if (rhsCt.canBeNumber()) {
      return CHAR;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == BOOLEAN) {
    if (rhsCt == BOOLEAN) {
      return BOOLEAN;
    }
    failComp(lhsCt,rhsCt);
  }
  if (lhsCt == PC && rhsCt == PC) {
    return PC;
  }
  if (lhsCt == STRING && rhsCt == STRING) {
    return STRING;
  }
  return UNKNOWN;
}
Program: 98003
Project: 98003
Buggy source:
/** 
 * Prints a debug message if the level is below or equal the  <code>verbosity</code> setting. The output can be redirected to the logging mechanism by setting the following property: <tt>verboseOutput = log</tt>.
 * @param level
 * @param message Message to print.
 */
public static final void debugPrint(int level,String... message){
  if (level <= verbosityLevel) {
    long tId=Thread.currentThread().getId();
    FormattedStringBuilder buf=new FormattedStringBuilder().append("String_Node_Str" + tId + "String_Node_Str").append(message);
    if (verboseToLog) {
      _LOGGER.info(buf.toString());
    }
 else {
      System.out.print(buf.toString());
    }
  }
}

Fixed version (ground truth):
/** 
 * Prints a debug message if the level is below or equal the  <code>verbosity</code> setting. The output can be redirected to the logging mechanism by setting the following property: <tt>verboseOutput = log</tt>.
 * @param level
 * @param message Message to print.
 */
public static final void debugPrint(int level,String... message){
  if (level <= verbosityLevel) {
    long tId=Thread.currentThread().getId();
    FormattedStringBuilder buf=new FormattedStringBuilder().append("String_Node_Str" + tId + "String_Node_Str").append(message);
    if (verboseToLog) {
      LOGGER.info(buf.toString());
    }
 else {
      System.out.print(buf.toString());
    }
  }
}
Program: 98005
Project: 98005
Buggy source:
@Test public void testParsing7(){
  PersistenceManager pm=TestTools.openPM();
  pm.currentTransaction().begin();
  try {
    Query q=pm.newQuery(TestClass.class,"String_Node_Str");
    q.execute();
    fail();
  }
 catch (  JDOUserException e) {
    e.printStackTrace();
    assertTrue(e.getMessage().contains("String_Node_Str"));
  }
}

Fixed version (ground truth):
@Test public void testParsing7(){
  PersistenceManager pm=TestTools.openPM();
  pm.currentTransaction().begin();
  try {
    Query q=pm.newQuery(TestClass.class,"String_Node_Str");
    q.execute();
    fail();
  }
 catch (  JDOUserException e) {
    assertTrue(e.getMessage().contains("String_Node_Str"));
  }
}
Program: 98006
Project: 98006
Buggy source:
@Test public void testParsing11(){
  PersistenceManager pm=TestTools.openPM();
  pm.currentTransaction().begin();
  try {
    Query q=pm.newQuery(TestClass.class,"String_Node_Str");
    q.execute(0);
    fail();
  }
 catch (  JDOUserException e) {
    assertTrue(e.getMessage().contains("String_Node_Str"));
  }
}

Fixed version (ground truth):
@Test public void testParsing11(){
  PersistenceManager pm=TestTools.openPM();
  pm.currentTransaction().begin();
  try {
    Query q=pm.newQuery(TestClass.class,"String_Node_Str");
    q.execute(0);
    fail();
  }
 catch (  JDOUserException e) {
    e.printStackTrace();
    assertTrue(e.getMessage().contains("String_Node_Str"));
  }
}
Program: 98007
Project: 98007
Buggy source:
public final void jdoZooInit(ObjectState state,PCContext bundle,long oid){
  this.context=bundle;
  jdoZooSetOid(oid);
  this.status=state;
switch (state) {
case PERSISTENT_NEW:
{
      setPersNew();
      jdoZooSetTimestamp(bundle.getSession().getTransactionId());
      jdoZooGetContext().notifyEvent(this,ZooInstanceEvent.CREATE);
      break;
    }
case PERSISTENT_CLEAN:
{
    setPersClean();
    break;
  }
case HOLLOW_PERSISTENT_NONTRANSACTIONAL:
{
  setHollow();
  break;
}
default :
throw new UnsupportedOperationException("String_Node_Str" + state);
}
if (this instanceof PersistenceCapableImpl) {
((PersistenceCapableImpl)this).jdoNewInstance(StateManagerImpl.STATEMANAGER);
}
}

Fixed version (ground truth):
public final void jdoZooInit(ObjectState state,PCContext bundle,long oid){
  this.context=bundle;
  jdoZooSetOid(oid);
  this.status=state;
switch (state) {
case PERSISTENT_NEW:
{
      setPersNew();
      jdoZooSetTimestamp(bundle.getSession().getTransactionId());
      jdoZooGetContext().notifyEvent(this,ZooInstanceEvent.CREATE);
      break;
    }
case PERSISTENT_CLEAN:
{
    setPersClean();
    break;
  }
case HOLLOW_PERSISTENT_NONTRANSACTIONAL:
{
  setHollow();
  break;
}
case PERSISTENT_DIRTY:
{
if (!(this instanceof GenericObject)) {
  throw new UnsupportedOperationException("String_Node_Str" + state);
}
setPersDirty();
break;
}
default :
throw new UnsupportedOperationException("String_Node_Str" + state);
}
if (this instanceof PersistenceCapableImpl) {
((PersistenceCapableImpl)this).jdoNewInstance(StateManagerImpl.STATEMANAGER);
}
}
Program: 98008
Project: 98008
Buggy source:
private ZooClassDef evolve(){
  ArrayList<Object> fV=new ArrayList<Object>(Arrays.asList(fixedValues));
  ArrayList<Object> vV=new ArrayList<Object>(Arrays.asList(variableValues));
  for (  PersistentSchemaOperation op : jdoZooGetClassDef().getNextVersion().getEvolutionOps()) {
    if (op.isAddOp()) {
      fV.add(op.getFieldId(),op.getInitialValue());
      vV.add(op.getFieldId(),null);
    }
 else {
      fV.remove(op.getFieldId());
      vV.remove(op.getFieldId());
    }
  }
  fixedValues=fV.toArray(fixedValues);
  variableValues=vV.toArray(variableValues);
  defCurrent=defCurrent.getNextVersion();
  return defCurrent;
}

Fixed version (ground truth):
/** 
 * Schema evolution of in-memory objects, operation by operation.
 * @param op
 */
public void evolve(SchemaOperation op){
  ArrayList<Object> fV=new ArrayList<Object>(Arrays.asList(fixedValues));
  ArrayList<Object> vV=new ArrayList<Object>(Arrays.asList(variableValues));
  if (op instanceof SchemaOperation.SchemaFieldDefine) {
    SchemaOperation.SchemaFieldDefine op2=(SchemaFieldDefine)op;
    int fieldId=op2.getField().getFieldPos();
    fV.add(fieldId,PersistentSchemaOperation.getDefaultValue(op2.getField()));
    vV.add(fieldId,null);
  }
  if (op instanceof SchemaOperation.SchemaFieldDelete) {
    SchemaOperation.SchemaFieldDelete op2=(SchemaFieldDelete)op;
    int fieldId=op2.getField().getFieldPos();
    fV.remove(fieldId);
    vV.remove(fieldId);
  }
  fixedValues=fV.toArray(fixedValues);
  variableValues=vV.toArray(variableValues);
}
Program: 98009
Project: 98009
Buggy source:
private PersistentSchemaOperation(OP op,int fieldId,ZooFieldDef field,Object initialValue){
  this.op=op;
  this.fieldId=fieldId;
  this.field=field;
  if (initialValue == null) {
switch (field.getJdoType()) {
case PRIMITIVE:
switch (field.getPrimitiveType()) {
case BOOLEAN:
        initialValue=Boolean.valueOf(false);
      break;
case BYTE:
    initialValue=Byte.valueOf((byte)0);
  break;
case CHAR:
initialValue=Character.valueOf((char)0);
break;
case DOUBLE:
initialValue=Double.valueOf(0);
break;
case FLOAT:
initialValue=Float.valueOf(0);
break;
case INT:
initialValue=Integer.valueOf(0);
break;
case LONG:
initialValue=Long.valueOf(0L);
break;
case SHORT:
initialValue=Short.valueOf((short)0);
break;
default :
throw new IllegalArgumentException();
}
break;
case DATE:
case REFERENCE:
case NUMBER:
case ARRAY:
case BIG_DEC:
case BIG_INT:
case SCO:
case STRING:
initialValue=null;
break;
default :
throw new IllegalArgumentException();
}
}
this.initialValue=initialValue;
}

Fixed version (ground truth):
private PersistentSchemaOperation(OP op,int fieldId,ZooFieldDef field,Object initialValue){
  this.op=op;
  this.fieldId=fieldId;
  this.field=field;
  if (initialValue == null) {
    initialValue=getDefaultValue(field);
  }
  this.initialValue=initialValue;
}
Program: 98010
Project: 98010
Buggy source:
public void commit(boolean retainValues){
  try {
    lock();
    checkActive();
    cache.persistReachableObjects();
    processOptimisticVerification(false);
    try {
      schemaManager.commit();
      commitInternal();
      for (      Node n : nodes) {
        n.commit();
      }
      cache.postCommit(retainValues,config.getDetachAllOnCommit());
      schemaManager.postCommit();
    }
 catch (    RuntimeException e) {
      if (DBLogger.isUser(e)) {
        for (        ZooClassDef cs : cache.getSchemata()) {
          cs.getProvidedContext().getDataSink().reset();
          cs.getProvidedContext().getDataDeleteSink().reset();
        }
        for (        Node n : nodes) {
          n.revert();
        }
      }
      rollbackInteral();
      throw e;
    }
    for (    CloseableIterator<?> ext : extents.keySet().toArray(new CloseableIterator[0])) {
      ext.close();
    }
    isActive=false;
  }
  finally {
    unlock();
  }
}

Fixed version (ground truth):
public void commit(boolean retainValues){
  try {
    lock();
    checkActive();
    cache.persistReachableObjects();
    processOptimisticVerification(false);
    try {
      schemaManager.commit();
      commitInternal();
      for (      Node n : nodes) {
        n.commit();
      }
      cache.postCommit(retainValues,config.getDetachAllOnCommit());
      schemaManager.postCommit();
    }
 catch (    RuntimeException e) {
      try {
        if (DBLogger.isUser(e)) {
          for (          ZooClassDef cs : cache.getSchemata()) {
            cs.getProvidedContext().getDataSink().reset();
            cs.getProvidedContext().getDataDeleteSink().reset();
          }
          for (          Node n : nodes) {
            n.revert();
          }
        }
        rollbackInteral();
      }
 catch (      Throwable t) {
        DBLogger.severe("String_Node_Str" + t.getMessage());
        t.printStackTrace();
      }
      throw e;
    }
    for (    CloseableIterator<?> ext : extents.keySet().toArray(new CloseableIterator[0])) {
      ext.close();
    }
    isActive=false;
  }
  finally {
    unlock();
  }
}
Program: 98011
Project: 98011
Buggy source:
public ZooClassDef removeField(ZooFieldDef field){
  ZooClassDef def=field.getDeclaringType().getModifiableVersion(cache,ops);
  field=def.getField(field.getName());
  ops.add(new SchemaOperation.SchemaFieldDelete(def,field));
  return def;
}

Fixed version (ground truth):
public ZooClassDef removeField(ZooFieldDef field){
  ZooClassDef def=field.getDeclaringType().getModifiableVersion(cache,ops);
  field=def.getField(field.getName());
  applyOp(new SchemaOperation.SchemaFieldDelete(def,field),def);
  return def;
}
Program: 98012
Project: 98012
Buggy source:
public ZooFieldDef addField(ZooClassDef def,String fieldName,ZooClassDef typeDef,int arrayDim){
  def=def.getModifiableVersion(cache,ops);
  ZooFieldDef field=ZooFieldDef.create(def,fieldName,typeDef,arrayDim);
  ops.add(new SchemaOperation.SchemaFieldDefine(def,field));
  return field;
}

Fixed version (ground truth):
public ZooFieldDef addField(ZooClassDef def,String fieldName,ZooClassDef typeDef,int arrayDim){
  def=def.getModifiableVersion(cache,ops);
  ZooFieldDef field=ZooFieldDef.create(def,fieldName,typeDef,arrayDim);
  applyOp(new SchemaOperation.SchemaFieldDefine(def,field),def);
  return field;
}
Program: 98014
Project: 98014
Buggy source:
@Override public void commit(){
  try {
    int oidPage=oidIndex.write();
    int schemaPage1=schemaIndex.write(txId);
    txContext.setSchemaTxId(schemaIndex.getTxIdOfLastWrite());
    txContext.setSchemaIndexTxId(schemaIndex.getTxIdOfLastWriteThatRequiresRefresh());
    sm.commitInfrastructure(oidPage,schemaPage1,oidIndex.getLastUsedOid(),txId);
    txContext.reset();
  }
  finally {
    DBLogger.debugPrintln(1,"String_Node_Str");
    sm.getLock().release(this);
  }
}

Fixed version (ground truth):
@Override public void commit(){
  int oidPage=oidIndex.write();
  int schemaPage1=schemaIndex.write(txId);
  txContext.setSchemaTxId(schemaIndex.getTxIdOfLastWrite());
  txContext.setSchemaIndexTxId(schemaIndex.getTxIdOfLastWriteThatRequiresRefresh());
  sm.commitInfrastructure(oidPage,schemaPage1,oidIndex.getLastUsedOid(),txId);
  txContext.reset();
  DBLogger.debugPrintln(1,"String_Node_Str");
  sm.getLock().release(this);
}
Program: 98015
Project: 98015
Buggy source:
private void releaseWrite(T key){
  if (currentWriterKey != key) {
    throw new IllegalStateException();
  }
  currentWriterKey=NO_KEY;
  wSemaphore.release();
}

Fixed version (ground truth):
private void releaseWrite(T key){
  if (currentWriterKey != key) {
    new IllegalStateException().printStackTrace();
    return;
  }
  currentWriterKey=NO_KEY;
  wSemaphore.release();
}
Program: 98016
Project: 98016
Buggy source:
private void releaseRead(T key){
  if (rSemaphore.availablePermits() == MAX_READERS) {
    throw new IllegalStateException();
  }
  rSemaphore.release();
}

Fixed version (ground truth):
private void releaseRead(T key){
  if (rSemaphore.availablePermits() == MAX_READERS) {
    new IllegalStateException().printStackTrace();
    return;
  }
  rSemaphore.release();
}
Program: 98017
Project: 98017
Buggy source:
@Override public void close(){
  for (  PersistenceManagerImpl pm : pms) {
    if (!pm.isClosed() && pm.currentTransaction().isActive()) {
      throw new JDOUserException("String_Node_Str",new JDOUserException(),pm);
    }
  }
  while (!pms.isEmpty()) {
    PersistenceManager pm=pms.iterator().next();
    if (!pm.isClosed()) {
      pm.close();
    }
  }
  JDOImplHelper.getInstance().removeStateInterrogation(SI);
  isClosed=true;
}

Fixed version (ground truth):
@Override public void close(){
  for (  PersistenceManagerImpl pm : pms) {
    if (!pm.isClosed() && pm.currentTransaction().isActive()) {
      throw new JDOUserException("String_Node_Str",new JDOUserException(),pm);
    }
  }
  while (!pms.isEmpty()) {
    PersistenceManager pm=pms.iterator().next();
    if (!pm.isClosed()) {
      pm.close();
    }
 else {
      pms.remove(pm);
    }
  }
  JDOImplHelper.getInstance().removeStateInterrogation(SI);
  isClosed=true;
}
Program: 98018
Project: 98018
Buggy source:
public long[] jdoZooGetBackup(){
  return prevValues;
}

Fixed version (ground truth):
public Pair<long[],Object[]> jdoZooGetBackup(){
  return prevValues;
}
Program: 98019
Project: 98019
Buggy source:
public final long[] getBackup(GenericObject co,Object[] raw){
  if (indFields.length == 0) {
    return null;
  }
  long[] la=new long[indFields.length];
  for (int i=0; i < indFields.length; i++) {
    ZooFieldDef fd=indFields[i];
    PRIMITIVE p=fd.getPrimitiveType();
    if (p != null) {
      la[i]=SerializerTools.primitiveToLong(raw[fd.getFieldPos()],p);
    }
 else {
      la[i]=(Long)raw[fd.getFieldPos()];
    }
  }
  return la;
}

Fixed version (ground truth):
public final Pair<long[],Object[]> getBackup(GenericObject co,Object[] raw){
  if (indFields.length == 0) {
    return null;
  }
  Pair<long[],Object[]> ret=new Pair<long[],Object[]>(new long[indFields.length],new Object[indFields.length]);
  for (int i=0; i < indFields.length; i++) {
    ZooFieldDef fd=indFields[i];
    PRIMITIVE p=fd.getPrimitiveType();
    if (p != null) {
      ret.getA()[i]=SerializerTools.primitiveToLong(raw[fd.getFieldPos()],p);
    }
 else {
      ret.getA()[i]=(Long)raw[fd.getFieldPos()];
      ret.getB()[i]=co.getField(fd);
    }
  }
  return ret;
}
Program: 98020
Project: 98020
Buggy source:
private void updateFieldIndicesGO(){
  final GenericObject[] buffer=this.bufferGO;
  final int bufferCnt=this.bufferGOCnt;
  int iInd=-1;
  for (  ZooFieldDef field : cls.getAllFields()) {
    if (!field.isIndexed()) {
      continue;
    }
    iInd++;
    SchemaIndexEntry schemaTop=node.getSchemaIE(field.getDeclaringType());
    LongLongIndex fieldInd=(LongLongIndex)schemaTop.getIndex(field);
    try {
      for (int i=0; i < bufferCnt; i++) {
        GenericObject co=buffer[i];
        if (co.jdoZooGetBackup() != null) {
          long l=co.jdoZooGetBackup()[iInd];
          fieldInd.removeLong(l,co.getOid());
          continue;
        }
        long l;
        if (field.isString()) {
          if (co.jdoZooIsStateHollow()) {
            throw new UnsupportedOperationException();
          }
          l=(Long)co.getFieldRaw(field.getFieldPos());
        }
 else {
          Object primO=co.getFieldRaw(field.getFieldPos());
          l=SerializerTools.primitiveToLong(primO,field.getPrimitiveType());
        }
        fieldInd.removeLong(l,co.getOid());
      }
    }
 catch (    IllegalArgumentException e) {
      throw DBLogger.newFatal("String_Node_Str" + field.getName(),e);
    }
  }
  PagedPosIndex ois=sie.getObjectIndexLatestSchemaVersion();
  for (int i=0; i < bufferCnt; i++) {
    long oid=buffer[i].getOid();
    delete(oid,ois);
  }
}

Fixed version (ground truth):
private void updateFieldIndicesGO(){
  final GenericObject[] buffer=this.bufferGO;
  final int bufferCnt=this.bufferGOCnt;
  int iInd=-1;
  for (  ZooFieldDef field : cls.getAllFields()) {
    if (!field.isIndexed()) {
      continue;
    }
    iInd++;
    SchemaIndexEntry schemaTop=node.getSchemaIE(field.getDeclaringType());
    LongLongIndex fieldInd=(LongLongIndex)schemaTop.getIndex(field);
    try {
      for (int i=0; i < bufferCnt; i++) {
        GenericObject co=buffer[i];
        if (co.jdoZooGetBackup() != null) {
          long l=co.jdoZooGetBackup().getA()[iInd];
          fieldInd.removeLong(l,co.getOid());
          continue;
        }
        long l;
        if (field.isString()) {
          if (co.jdoZooIsStateHollow()) {
            throw new UnsupportedOperationException();
          }
          l=(Long)co.getFieldRaw(field.getFieldPos());
        }
 else {
          Object primO=co.getFieldRaw(field.getFieldPos());
          l=SerializerTools.primitiveToLong(primO,field.getPrimitiveType());
        }
        fieldInd.removeLong(l,co.getOid());
      }
    }
 catch (    IllegalArgumentException e) {
      throw DBLogger.newFatal("String_Node_Str" + field.getName(),e);
    }
  }
  PagedPosIndex ois=sie.getObjectIndexLatestSchemaVersion();
  for (int i=0; i < bufferCnt; i++) {
    long oid=buffer[i].getOid();
    delete(oid,ois);
  }
}
Program: 98021
Project: 98021
Buggy source:
private void updateFieldIndices(){
  final ZooPC[] buffer=this.buffer;
  final int bufferCnt=this.bufferCnt;
  int iInd=-1;
  for (  ZooFieldDef field : cls.getAllFields()) {
    if (!field.isIndexed()) {
      continue;
    }
    iInd++;
    SchemaIndexEntry schemaTop=node.getSchemaIE(field.getDeclaringType());
    LongLongIndex fieldInd=(LongLongIndex)schemaTop.getIndex(field);
    try {
      Field jField=field.getJavaField();
      for (int i=0; i < bufferCnt; i++) {
        ZooPC co=buffer[i];
        if (co.jdoZooGetBackup() != null) {
          long l=co.jdoZooGetBackup()[iInd];
          fieldInd.removeLong(l,co.jdoZooGetOid());
          continue;
        }
        long l;
        if (field.isString()) {
          String str=(String)jField.get(co);
          l=BitTools.toSortableLong(str);
        }
 else {
          l=SerializerTools.primitiveFieldToLong(co,jField,field.getPrimitiveType());
        }
        fieldInd.removeLong(l,co.jdoZooGetOid());
      }
    }
 catch (    SecurityException e) {
      throw DBLogger.newFatal("String_Node_Str" + field.getName(),e);
    }
catch (    IllegalArgumentException e) {
      throw DBLogger.newFatal("String_Node_Str" + field.getName(),e);
    }
catch (    IllegalAccessException e) {
      throw DBLogger.newFatal("String_Node_Str" + field.getName(),e);
    }
  }
  PagedPosIndex ois=sie.getObjectIndexLatestSchemaVersion();
  for (int i=0; i < bufferCnt; i++) {
    long oid=buffer[i].jdoZooGetOid();
    delete(oid,ois);
  }
}

Fixed version (ground truth):
private void updateFieldIndices(){
  final ZooPC[] buffer=this.buffer;
  final int bufferCnt=this.bufferCnt;
  int iInd=-1;
  for (  ZooFieldDef field : cls.getAllFields()) {
    if (!field.isIndexed()) {
      continue;
    }
    iInd++;
    SchemaIndexEntry schemaTop=node.getSchemaIE(field.getDeclaringType());
    LongLongIndex fieldInd=(LongLongIndex)schemaTop.getIndex(field);
    try {
      Field jField=field.getJavaField();
      for (int i=0; i < bufferCnt; i++) {
        ZooPC co=buffer[i];
        if (co.jdoZooGetBackup() != null) {
          long l=co.jdoZooGetBackup().getA()[iInd];
          fieldInd.removeLong(l,co.jdoZooGetOid());
          continue;
        }
        long l;
        if (field.isString()) {
          String str=(String)jField.get(co);
          l=BitTools.toSortableLong(str);
        }
 else {
          l=SerializerTools.primitiveFieldToLong(co,jField,field.getPrimitiveType());
        }
        fieldInd.removeLong(l,co.jdoZooGetOid());
      }
    }
 catch (    SecurityException e) {
      throw DBLogger.newFatal("String_Node_Str" + field.getName(),e);
    }
catch (    IllegalArgumentException e) {
      throw DBLogger.newFatal("String_Node_Str" + field.getName(),e);
    }
catch (    IllegalAccessException e) {
      throw DBLogger.newFatal("String_Node_Str" + field.getName(),e);
    }
  }
  PagedPosIndex ois=sie.getObjectIndexLatestSchemaVersion();
  for (int i=0; i < bufferCnt; i++) {
    long oid=buffer[i].jdoZooGetOid();
    delete(oid,ois);
  }
}
Program: 98023
Project: 98023
Buggy source:
private void flushBuffer(){
  updateFieldIndices();
  bufferCnt=0;
  if (bufferGOCnt > 0) {
    updateFieldIndicesGO();
    bufferGOCnt=0;
  }
  for (int i=0; i < fieldUpdateBuffer.length; i++) {
    ArrayList<Pair> a=fieldUpdateBuffer[i];
    if (a != null) {
      ZooFieldDef field=cls.getAllFields()[i];
      if (!field.isIndexed()) {
        continue;
      }
      SchemaIndexEntry schemaTop=node.getSchemaIE(field.getDeclaringType());
      LongLongIndex fieldInd=(LongLongIndex)schemaTop.getIndex(field);
      for (      Pair p : a) {
        if (!fieldInd.insertLongIfNotSet(p.value,p.oid)) {
          long x=fieldInd.iterator(p.value,p.value).next().getValue();
          throw DBLogger.newUser("String_Node_Str" + field.getName() + "String_Node_Str"+ p.value+ "String_Node_Str"+ Util.oidToString(p.oid)+ "String_Node_Str"+ Util.oidToString(x));
        }
      }
      fieldUpdateBuffer[i]=null;
    }
  }
}

Fixed version (ground truth):
private void flushBuffer(){
  updateFieldIndices();
  bufferCnt=0;
  if (bufferGOCnt > 0) {
    updateFieldIndicesGO();
    bufferGOCnt=0;
  }
  for (int i=0; i < fieldUpdateBuffer.length; i++) {
    ArrayList<Pair> a=fieldUpdateBuffer[i];
    if (a != null) {
      ZooFieldDef field=cls.getAllFields()[i];
      if (!field.isIndexed()) {
        continue;
      }
      SchemaIndexEntry schemaTop=node.getSchemaIE(field.getDeclaringType());
      LongLongIndex fieldInd=(LongLongIndex)schemaTop.getIndex(field);
      for (      Pair p : a) {
        if (field.isString()) {
          String str=getString(p.pc,field);
          if (str != null) {
            Iterator<ZooPC> it=node.readObjectFromIndex(field,p.value,p.value,true);
            while (it.hasNext()) {
              ZooPC o2=it.next();
              String s2=getString(o2,field);
              if (str.equals(s2)) {
                long oid2=o2.jdoZooGetOid();
                throw DBLogger.newUser("String_Node_Str" + field.getName() + "String_Node_Str"+ p.value+ "String_Node_Str"+ Util.oidToString(p.pc.jdoZooGetOid())+ "String_Node_Str"+ Util.oidToString(oid2));
              }
            }
          }
          fieldInd.insertLong(p.value,p.pc.jdoZooGetOid());
        }
 else         if (!fieldInd.insertLongIfNotSet(p.value,p.pc.jdoZooGetOid())) {
          long oid2=fieldInd.iterator(p.value,p.value).next().getValue();
          throw DBLogger.newUser("String_Node_Str" + field.getName() + "String_Node_Str"+ p.value+ "String_Node_Str"+ Util.oidToString(p.pc.jdoZooGetOid())+ "String_Node_Str"+ Util.oidToString(oid2));
        }
      }
      fieldUpdateBuffer[i]=null;
    }
  }
}
Program: 98024
Project: 98024
Buggy source:
public Pair(long oid,long value){
  this.oid=oid;
  this.value=value;
}

Fixed version (ground truth):
public Pair(ZooPC pc,long value){
  this.pc=pc;
  this.value=value;
}
Program: 98026
Project: 98026
Buggy source:
public LongLongIndex getIndex(ZooFieldDef field){
  for (  FieldIndex fi : fieldIndices) {
    if (fi.fieldId == field.getFieldSchemaId()) {
      if (fi.index == null) {
        if (fi.isUnique) {
          fi.index=IndexFactory.loadUniqueIndex(DATA_TYPE.FIELD_INDEX,file,fi.page);
        }
 else {
          fi.index=IndexFactory.loadIndex(DATA_TYPE.FIELD_INDEX,file,fi.page);
        }
      }
      return fi.index;
    }
  }
  return null;
}

Fixed version (ground truth):
public LongLongIndex getIndex(ZooFieldDef field){
  for (  FieldIndex fi : fieldIndices) {
    if (fi.fieldId == field.getFieldSchemaId()) {
      if (fi.index == null) {
        if (fi.isUnique && !field.isString()) {
          fi.index=IndexFactory.loadUniqueIndex(DATA_TYPE.FIELD_INDEX,file,fi.page);
        }
 else {
          fi.index=IndexFactory.loadIndex(DATA_TYPE.FIELD_INDEX,file,fi.page);
        }
      }
      return fi.index;
    }
  }
  return null;
}
Program: 98027
Project: 98027
Buggy source:
void addVersion(ZooClassDef defNew){
  int newLen=defNew.getSchemaVersion() + 1;
  schemaOids=Arrays.copyOf(schemaOids,newLen);
  objIndexPages=Arrays.copyOf(objIndexPages,newLen);
  objIndex=Arrays.copyOf(objIndex,newLen);
  objIndex[newLen - 1]=PagedPosIndex.newIndex(file);
  schemaOids[newLen - 1]=defNew.getOid();
  for (  PersistentSchemaOperation op : defNew.getEvolutionOps()) {
    if (op.isAddOp() && op.getField().isIndexed()) {
      ZooFieldDef field=op.getField();
      FieldIndex fi=new FieldIndex();
      fi.fieldId=op.getFieldId();
      fi.fType=FTYPE.fromType(field.getTypeName());
      fi.isUnique=field.isIndexUnique();
      if (fi.isUnique) {
        fi.index=IndexFactory.createUniqueIndex(DATA_TYPE.FIELD_INDEX,file);
      }
 else {
        fi.index=IndexFactory.createIndex(DATA_TYPE.FIELD_INDEX,file);
      }
      fieldIndices.add(fi);
    }
 else {
      for (int i=0; i < fieldIndices.size(); i++) {
        if (fieldIndices.get(i).fieldId == op.getFieldId()) {
          FieldIndex fi=fieldIndices.remove(i);
          fi.index.clear();
        }
      }
    }
  }
}

Fixed version (ground truth):
void addVersion(ZooClassDef defNew){
  int newLen=defNew.getSchemaVersion() + 1;
  schemaOids=Arrays.copyOf(schemaOids,newLen);
  objIndexPages=Arrays.copyOf(objIndexPages,newLen);
  objIndex=Arrays.copyOf(objIndex,newLen);
  objIndex[newLen - 1]=PagedPosIndex.newIndex(file);
  schemaOids[newLen - 1]=defNew.getOid();
  for (  PersistentSchemaOperation op : defNew.getEvolutionOps()) {
    if (op.isAddOp() && op.getField().isIndexed()) {
      ZooFieldDef field=op.getField();
      FieldIndex fi=new FieldIndex();
      fi.fieldId=op.getFieldId();
      fi.fType=FTYPE.fromType(field.getTypeName());
      fi.isUnique=field.isIndexUnique();
      if (fi.isUnique && !field.isString()) {
        fi.index=IndexFactory.createUniqueIndex(DATA_TYPE.FIELD_INDEX,file);
      }
 else {
        fi.index=IndexFactory.createIndex(DATA_TYPE.FIELD_INDEX,file);
      }
      fieldIndices.add(fi);
    }
 else {
      for (int i=0; i < fieldIndices.size(); i++) {
        if (fieldIndices.get(i).fieldId == op.getFieldId()) {
          FieldIndex fi=fieldIndices.remove(i);
          fi.index.clear();
        }
      }
    }
  }
}
Program: 98028
Project: 98028
Buggy source:
public LongLongIndex defineIndex(ZooFieldDef field,boolean isUnique){
  if (!field.isPrimitiveType() && !field.isString()) {
    throw new IllegalArgumentException("String_Node_Str" + field.getTypeName());
  }
  for (  FieldIndex fi : fieldIndices) {
    if (fi.fieldId == field.getFieldSchemaId()) {
      throw new IllegalArgumentException("String_Node_Str" + field.getName());
    }
  }
  FieldIndex fi=new FieldIndex();
  fi.fieldId=field.getFieldSchemaId();
  fi.fType=FTYPE.fromType(field.getTypeName());
  fi.isUnique=isUnique;
  field.setIndexed(true);
  field.setUnique(isUnique);
  if (isUnique) {
    fi.index=IndexFactory.createUniqueIndex(DATA_TYPE.FIELD_INDEX,file);
  }
 else {
    fi.index=IndexFactory.createIndex(DATA_TYPE.FIELD_INDEX,file);
  }
  fieldIndices.add(fi);
  markRefreshRequired();
  return fi.index;
}

Fixed version (ground truth):
public LongLongIndex defineIndex(ZooFieldDef field,boolean isUnique){
  if (!field.isPrimitiveType() && !field.isString()) {
    throw new IllegalArgumentException("String_Node_Str" + field.getTypeName());
  }
  for (  FieldIndex fi : fieldIndices) {
    if (fi.fieldId == field.getFieldSchemaId()) {
      throw new IllegalArgumentException("String_Node_Str" + field.getName());
    }
  }
  FieldIndex fi=new FieldIndex();
  fi.fieldId=field.getFieldSchemaId();
  fi.fType=FTYPE.fromType(field.getTypeName());
  fi.isUnique=isUnique;
  field.setIndexed(true);
  field.setUnique(isUnique);
  if (isUnique && !field.isString()) {
    fi.index=IndexFactory.createUniqueIndex(DATA_TYPE.FIELD_INDEX,file);
  }
 else {
    fi.index=IndexFactory.createIndex(DATA_TYPE.FIELD_INDEX,file);
  }
  fieldIndices.add(fi);
  markRefreshRequired();
  return fi.index;
}
Program: 98029
Project: 98029
Buggy source:
@Test public void testStringIndexCollisionBug_Issue_55(){
  TestTools.defineIndex(TestClass.class,"String_Node_Str",true);
  PersistenceManager pm=TestTools.openPM();
  pm.currentTransaction().begin();
  TestClass t1=new TestClass();
  t1.setString("String_Node_Str");
  pm.makePersistent(t1);
  TestClass t2=new TestClass();
  t2.setString("String_Node_Str");
  pm.makePersistent(t2);
  long hash1=BitTools.toSortableLong(t1.getString());
  long hash2=BitTools.toSortableLong(t2.getString());
  System.out.println(BitTools.toSortableLong(t1.getString()));
  System.out.println(BitTools.toSortableLong(t2.getString()));
  assertEquals(hash1,hash2);
  pm.currentTransaction().commit();
  pm.currentTransaction().begin();
  Collection<?> c=(Collection<?>)pm.newQuery(TestClass.class).execute();
  assertEquals(2,c.size());
  assertTrue(c.contains(t1));
  assertTrue(c.contains(t2));
  pm.currentTransaction().commit();
  TestTools.closePM();
}

Fixed version (ground truth):
@Test public void testStringIndexCollisionBug_Issue_55(){
  TestTools.defineIndex(TestClass.class,"String_Node_Str",true);
  PersistenceManager pm=TestTools.openPM();
  pm.currentTransaction().begin();
  TestClass t1=new TestClass();
  t1.setString("String_Node_Str");
  pm.makePersistent(t1);
  TestClass t2=new TestClass();
  t2.setString("String_Node_Str");
  pm.makePersistent(t2);
  long hash1=BitTools.toSortableLong(t1.getString());
  long hash2=BitTools.toSortableLong(t2.getString());
  System.out.println(BitTools.toSortableLong(t1.getString()));
  System.out.println(BitTools.toSortableLong(t2.getString()));
  assertEquals(hash1,hash2);
  pm.currentTransaction().commit();
  pm.currentTransaction().begin();
  Collection<?> c=(Collection<?>)pm.newQuery(TestClass.class).execute();
  assertEquals(2,c.size());
  assertTrue(c.contains(t1));
  assertTrue(c.contains(t2));
  pm.currentTransaction().commit();
  pm.currentTransaction().begin();
  t2.setString(t1.getString());
  try {
    pm.currentTransaction().commit();
    fail();
  }
 catch (  JDOUserException e) {
  }
  pm.currentTransaction().begin();
  t2.setString(null);
  t1.setString(null);
  pm.currentTransaction().commit();
  TestTools.closePM();
}
Program: 98030
Project: 98030
Buggy source:
public ZooClassDef getModifiableVersion(ClientSessionCache cache,List<SchemaOperation> ops,ZooClassDef newSuper){
  if (this.jdoZooIsNew()) {
    ensureLatestSuper();
    return this;
  }
  ZooClassDef defNew=newVersion(cache,ops,newSuper);
  ops.add(new SchemaOperation.SchemaNewVersion(this,defNew,cache));
  for (  ZooClassProxy sub : versionProxy.getSubProxies()) {
    sub.getSchemaDef().getModifiableVersion(cache,ops,defNew);
  }
  return defNew;
}

Fixed version (ground truth):
public ZooClassDef getModifiableVersion(ClientSessionCache cache,List<SchemaOperation> ops,ZooClassDef newSuper){
  if (this.jdoZooIsNew()) {
    ensureLatestSuper();
    return this;
  }
  ZooClassDef defNew=newVersion(cache,newSuper);
  ops.add(new SchemaOperation.SchemaNewVersion(this,defNew,cache));
  for (  ZooClassProxy sub : versionProxy.getSubProxies()) {
    sub.getSchemaDef().getModifiableVersion(cache,ops,defNew);
  }
  return defNew;
}
Program: 98031
Project: 98031
Buggy source:
/** 
 * Schema versioning: We only create new schema instance when we add or remove fields. Renaming a field should not result in a new version! A new version is only required when the modified schema does not match the stored data. Such changes require also new versions of all sub-classes.  WHY? If every class stored only their own fields would we still have a problem? Yes, because the new version of the referenced superclass has a different OID.
 * @param cache 
 * @return New version.
 */
private ZooClassDef newVersion(ClientSessionCache cache,List<SchemaOperation> ops,ZooClassDef newSuper){
  if (nextVersion != null) {
    throw new IllegalStateException();
  }
  if (newSuper == null) {
    newSuper=superDef;
  }
  long oid=jdoZooGetContext().getNode().getOidBuffer().allocateOid();
  ZooClassDef newDef=new ZooClassDef(className,oid,newSuper.getOid(),schemaId,versionId + 1);
  newDef.associateSuperDef(newSuper);
  cache.addSchema(newDef,false,jdoZooGetContext().getNode());
  newDef.prevVersionOid=jdoZooGetOid();
  newDef.prevVersion=this;
  nextVersion=newDef;
  newDef.versionProxy=versionProxy;
  versionProxy.newVersion(newDef);
  newDef.providedContext=new PCContext(newDef,providedContext.getSession(),providedContext.getNode());
  for (  ZooFieldDef f : localFields) {
    ZooFieldDef fNew=new ZooFieldDef(f,newDef);
    newDef.localFields.add(fNew);
    if (fNew.getProxy() != null) {
      fNew.getProxy().updateVersion(fNew);
    }
  }
  newDef.associateFields();
  return newDef;
}

Fixed version (ground truth):
/** 
 * Schema versioning: We only create new schema instance when we add or remove fields. Renaming a field should not result in a new version! A new version is only required when the modified schema does not match the stored data. Such changes require also new versions of all sub-classes.  WHY? If every class stored only their own fields would we still have a problem? Yes, because the new version of the referenced superclass has a different OID.
 * @param cache 
 * @return New version.
 */
private ZooClassDef newVersion(ClientSessionCache cache,ZooClassDef newSuper){
  if (nextVersion != null) {
    throw new IllegalStateException();
  }
  if (newSuper == null) {
    newSuper=superDef;
  }
  long oid=jdoZooGetContext().getNode().getOidBuffer().allocateOid();
  ZooClassDef newDef=new ZooClassDef(className,oid,newSuper.getOid(),schemaId,versionId + 1);
  newDef.associateSuperDef(newSuper);
  cache.addSchema(newDef,false,jdoZooGetContext().getNode());
  newDef.prevVersionOid=jdoZooGetOid();
  newDef.prevVersion=this;
  nextVersion=newDef;
  newDef.versionProxy=versionProxy;
  versionProxy.newVersion(newDef);
  newDef.providedContext=new PCContext(newDef,providedContext.getSession(),providedContext.getNode());
  for (  ZooFieldDef f : localFields) {
    ZooFieldDef fNew=new ZooFieldDef(f,newDef);
    newDef.localFields.add(fNew);
    if (fNew.getProxy() != null) {
      fNew.getProxy().updateVersion(fNew);
    }
  }
  newDef.associateFields();
  return newDef;
}
Program: 98032
Project: 98032
Buggy source:
/** 
 * This class is only public so it can be accessed by the test harness.  Please do not use.
 */
public final void traverse(){
  if (!traversalRequired || !cache.hasDirtyPojos()) {
    return;
  }
  traverseCache();
  traverseWorkList();
  traversalRequired=false;
}

Fixed version (ground truth):
/** 
 * This class is only public so it can be accessed by the test harness.  Please do not use.
 */
public final void traverse(){
  if (!traversalRequired && !cache.hasDirtyPojos()) {
    return;
  }
  traverseCache();
  traverseWorkList();
  traversalRequired=false;
}
Program: 98034
Project: 98034
Buggy source:
public static void removeSchema(Class<?>... classes){
  Properties props=new ZooJdoProperties(DB_NAME);
  PersistenceManagerFactory pmf=JDOHelper.getPersistenceManagerFactory(props);
  PersistenceManager pm=null;
  try {
    pm=pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    for (    Class<?> cls : classes) {
      ZooJdoHelper.schema(pm).getClass(cls).remove();
    }
    pm.currentTransaction().commit();
  }
  finally {
    safeClose(pmf,pm);
  }
}

Fixed version (ground truth):
public static void removeSchema(Class<?>... classes){
  Properties props=new ZooJdoProperties(DB_NAME);
  PersistenceManagerFactory pmf=JDOHelper.getPersistenceManagerFactory(props);
  PersistenceManager pm=null;
  try {
    pm=pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    for (    Class<?> cls : classes) {
      ZooClass c=ZooJdoHelper.schema(pm).getClass(cls);
      if (c != null) {
        c.remove();
      }
    }
    pm.currentTransaction().commit();
  }
  finally {
    safeClose(pmf,pm);
  }
}