nus-yam/ex-repair huggingface dataset:
Program: 42201
Project: 42201
Buggy source:
/** 
 * Checks whether the SAFA aut is empty
 * @throws TimeoutException
 */
public static <P,S,E extends BooleanExpression>boolean isEmpty(SAFA<P,S> aut,BooleanAlgebra<P,S> ba) throws TimeoutException {
  BooleanExpressionFactory<PositiveBooleanExpression> boolexpr=getBooleanExpressionFactory();
  return isEquivalent(aut,getEmptySAFA(ba),ba,boolexpr);
}

Fixed version (ground truth):
/** 
 * Checks whether the SAFA aut is empty
 * @throws TimeoutException
 */
public static <P,S,E extends BooleanExpression>boolean isEmpty(SAFA<P,S> aut,BooleanAlgebra<P,S> ba) throws TimeoutException {
  BooleanExpressionFactory<PositiveBooleanExpression> boolexpr=getBooleanExpressionFactory();
  return isEquivalent(aut,getEmptySAFA(ba),ba,boolexpr).getFirst();
}
Program: 42202
Project: 42202
Buggy source:
private void addTransition(SAFAInputMove<P,S> transition,BooleanAlgebra<P,S> ba,boolean skipSatCheck){
  if (skipSatCheck || transition.isSatisfiable(ba)) {
    transitionCount++;
    if (transition.from > maxStateId)     maxStateId=transition.from;
    if (transition.maxState > maxStateId)     maxStateId=transition.maxState;
    states.add(transition.from);
    states.addAll(transition.toStates);
    getInputMovesFrom(transition.from).add((SAFAInputMove<P,S>)transition);
  }
}

Fixed version (ground truth):
private void addTransition(SAFAInputMove<P,S> transition,BooleanAlgebra<P,S> ba,boolean skipSatCheck){
  if (skipSatCheck || transition.isSatisfiable(ba)) {
    transitionCount++;
    if (transition.from > maxStateId)     maxStateId=transition.from;
    if (transition.maxState > maxStateId)     maxStateId=transition.maxState;
    states.add(transition.from);
    states.addAll(transition.toStates);
    getInputMovesFrom(transition.from).add(transition);
  }
}
Program: 42203
Project: 42203
Buggy source:
public SAFAInputMove(Integer from,PositiveBooleanExpression to,P guard){
  super();
  this.from=from;
  this.to=to;
  toStates=to.getStates();
  maxState=Collections.max(toStates);
  this.guard=guard;
}

Fixed version (ground truth):
public SAFAInputMove(Integer from,PositiveBooleanExpression to,P guard){
  super();
  this.from=from;
  this.to=to;
  toStates=to.getStates();
  if (toStates.isEmpty()) {
    maxState=-1;
  }
 else {
    maxState=Collections.max(toStates);
  }
  if (maxState < from) {
    maxState=from;
  }
  this.guard=guard;
}
Program: 42204
Project: 42204
Buggy source:
/** 
 * Add a pair to the relation
 * @param p
 * @param q
 */
public abstract void add(BooleanExpression p,BooleanExpression q);

Fixed version (ground truth):
/** 
 * Add a pair to the relation
 * @param p
 * @param q
 */
public abstract boolean add(BooleanExpression p,BooleanExpression q);
Program: 42205
Project: 42205
Buggy source:
public void add(BooleanExpression p,BooleanExpression q){
  VecInt pair=new VecInt();
  pair.push(mkIff(p,q));
  factory.unsafeAddClause(pair);
}

Fixed version (ground truth):
public boolean add(BooleanExpression p,BooleanExpression q){
  VecInt pair=new VecInt();
  pair.push(mkIff(p,q));
  try {
    factory.solver.addClause(pair);
    return true;
  }
 catch (  ContradictionException e) {
    return false;
  }
}
Program: 42206
Project: 42206
Buggy source:
@Override public PositiveBooleanExpression MkOr(PositiveBooleanExpression phi,PositiveBooleanExpression psi){
  if (phi instanceof PositiveTrue || psi instanceof PositiveTrue) {
    return False();
  }
 else   if (phi instanceof PositiveFalse) {
    return psi;
  }
 else   if (psi instanceof PositiveFalse) {
    return phi;
  }
 else {
    return mkOr.apply(new Pair<>(phi,psi));
  }
}

Fixed version (ground truth):
@Override public PositiveBooleanExpression MkOr(PositiveBooleanExpression phi,PositiveBooleanExpression psi){
  if (phi instanceof PositiveTrue || psi instanceof PositiveTrue) {
    return True();
  }
 else   if (phi instanceof PositiveFalse) {
    return psi;
  }
 else   if (psi instanceof PositiveFalse) {
    return phi;
  }
 else {
    return mkOr.apply(new Pair<>(phi,psi));
  }
}
Program: 42207
Project: 42207
Buggy source:
@Test public void testLargeEquiv(){
  int size=7;
  LTLFormula<CharPred,Character> tot=new True<>();
  for (int i=100; i < 100 + size; i++) {
    CharPred ch=new CharPred((char)i);
    LTLFormula<CharPred,Character> evch=ev(ba,ch);
    tot=new And<>(evch,tot);
  }
  SAFA<CharPred,Character> safa1=tot.getSAFA(ba);
  tot=new True<>();
  for (int i=100; i < 100 + size - 1; i++) {
    CharPred ch=new CharPred((char)i);
    LTLFormula<CharPred,Character> evch=ev(ba,ch);
    tot=new And<>(evch,tot);
  }
  SAFA<CharPred,Character> safa2=tot.getSAFA(ba);
  long startTime=System.currentTimeMillis();
  boolean b=true;
  try {
    b=SAFA.isEquivalent(safa1,safa2,ba,SumOfProductsFactory.getInstance());
  }
 catch (  TimeoutException toe) {
    System.out.println(toe);
  }
  long stopTime=System.currentTimeMillis();
  long elapsedTime=stopTime - startTime;
  System.out.println(elapsedTime);
  startTime=System.currentTimeMillis();
  Pair<Boolean,List<Character>> b1=SAFA.areReverseEquivalent(safa1,safa2,ba);
  System.out.println(b1);
  stopTime=System.currentTimeMillis();
  elapsedTime=stopTime - startTime;
  System.out.println(elapsedTime);
  assertTrue(b == b1.first);
}

Fixed version (ground truth):
@Test public void testLargeEquiv(){
  int size=7;
  LTLFormula<CharPred,Character> tot=new True<>();
  for (int i=100; i < 100 + size; i++) {
    CharPred ch=new CharPred((char)i);
    LTLFormula<CharPred,Character> evch=ev(ba,ch);
    tot=new And<>(evch,tot);
  }
  SAFA<CharPred,Character> safa1=tot.getSAFA(ba);
  tot=new True<>();
  for (int i=100; i < 100 + size - 1; i++) {
    CharPred ch=new CharPred((char)i);
    LTLFormula<CharPred,Character> evch=ev(ba,ch);
    tot=new And<>(evch,tot);
  }
  SAFA<CharPred,Character> safa2=tot.getSAFA(ba);
  long startTime=System.currentTimeMillis();
  boolean b=true;
  try {
    b=SAFA.isEquivalent(safa1,safa2,ba,SumOfProductsFactory.getInstance()).first;
  }
 catch (  TimeoutException toe) {
    System.out.println(toe);
  }
  long stopTime=System.currentTimeMillis();
  long elapsedTime=stopTime - startTime;
  System.out.println(elapsedTime);
  startTime=System.currentTimeMillis();
  Pair<Boolean,List<Character>> b1=SAFA.areReverseEquivalent(safa1,safa2,ba);
  System.out.println(b1);
  stopTime=System.currentTimeMillis();
  elapsedTime=stopTime - startTime;
  System.out.println(elapsedTime);
  assertTrue(b == b1.first);
}
Program: 42208
Project: 42208
Buggy source:
@Test public void testLargeEmptinessBDD(){
  int sizeTot=14;
  BDDExpressionFactory bef=new BDDExpressionFactory(sizeTot);
  for (int size=10; size < sizeTot; size++) {
    BDDSolver bs=new BDDSolver(size);
    LTLFormula<BDD,BDD> tot=new True<>();
    List<LTLFormula<BDD,BDD>> conjuncts=new LinkedList<>();
    for (int i=0; i < size; i++) {
      conjuncts.add(new Eventually<>(new Predicate<BDD,BDD>(bs.factory.ithVar(i))));
    }
    tot=new And<>(conjuncts);
    long startTime=System.currentTimeMillis();
    SAFA<BDD,BDD> safa1=tot.getSAFA(bs);
    boolean b=true;
    try {
      b=SAFA.isEquivalent(safa1,SAFA.getEmptySAFA(bs),bs,bef);
      assertFalse(b);
    }
 catch (    Exception toe) {
      System.out.println(toe);
    }
    long stopTime=System.currentTimeMillis();
    long elapsedTime=stopTime - startTime;
    System.out.println(size + "String_Node_Str" + elapsedTime);
  }
}

Fixed version (ground truth):
@Test public void testLargeEmptinessBDD(){
  int sizeTot=12;
  BDDExpressionFactory bef=new BDDExpressionFactory(sizeTot);
  for (int size=10; size < sizeTot; size++) {
    BDDSolver bs=new BDDSolver(size);
    LTLFormula<BDD,BDD> tot=new True<>();
    List<LTLFormula<BDD,BDD>> conjuncts=new LinkedList<>();
    for (int i=0; i < size; i++) {
      conjuncts.add(new Eventually<>(new Predicate<BDD,BDD>(bs.factory.ithVar(i))));
    }
    tot=new And<>(conjuncts);
    long startTime=System.currentTimeMillis();
    SAFA<BDD,BDD> safa1=tot.getSAFA(bs);
    boolean b=true;
    try {
      b=SAFA.isEquivalent(safa1,SAFA.getEmptySAFA(bs),bs,bef).first;
      assertFalse(b);
    }
 catch (    Exception toe) {
      System.out.println(toe);
    }
    long stopTime=System.currentTimeMillis();
    long elapsedTime=stopTime - startTime;
    System.out.println(size + "String_Node_Str" + elapsedTime);
  }
}
Program: 42209
Project: 42209
Buggy source:
@Test public void testLargeEquivSAT() throws TimeoutException {
  int size=2;
  SATBooleanAlgebra ba=new SATBooleanAlgebra(size + 1);
  LTLFormula<Integer,boolean[]> tot=new True<>();
  List<LTLFormula<Integer,boolean[]>> conjuncts=new LinkedList<>();
  for (int i=1; i < size; i++) {
    conjuncts.add(new Eventually<>(new Predicate<Integer,boolean[]>(i)));
  }
  tot=new And<>(conjuncts);
  SAFA<Integer,boolean[]> safa1=tot.getSAFA(ba);
  tot=new True<>();
  for (int i=size - 1; i >= 1; i--) {
    LTLFormula<Integer,boolean[]> evch=new Eventually<>(new Predicate<Integer,boolean[]>(i));
    tot=new And<>(evch,tot);
  }
  SAFA<Integer,boolean[]> safa2=tot.getSAFA(ba);
  long startTime=System.currentTimeMillis();
  boolean b=true;
  try {
    b=SAFA.isEquivalent(safa1,safa2,ba,SumOfProductsFactory.getInstance());
  }
 catch (  TimeoutException toe) {
    System.out.println(toe);
  }
  long stopTime=System.currentTimeMillis();
  long elapsedTime=stopTime - startTime;
  System.out.println(elapsedTime);
  startTime=System.currentTimeMillis();
  Pair<Boolean,List<boolean[]>> b1=SAFA.areReverseEquivalent(safa1,safa2,ba);
  System.out.println(b1);
  stopTime=System.currentTimeMillis();
  elapsedTime=stopTime - startTime;
  System.out.println(elapsedTime);
  assertTrue(b == b1.first);
}

Fixed version (ground truth):
@Test public void testLargeEquivSAT() throws TimeoutException {
  int size=2;
  SATBooleanAlgebra ba=new SATBooleanAlgebra(size + 1);
  LTLFormula<Integer,boolean[]> tot=new True<>();
  List<LTLFormula<Integer,boolean[]>> conjuncts=new LinkedList<>();
  for (int i=1; i < size; i++) {
    conjuncts.add(new Eventually<>(new Predicate<Integer,boolean[]>(i)));
  }
  tot=new And<>(conjuncts);
  SAFA<Integer,boolean[]> safa1=tot.getSAFA(ba);
  tot=new True<>();
  for (int i=size - 1; i >= 1; i--) {
    LTLFormula<Integer,boolean[]> evch=new Eventually<>(new Predicate<Integer,boolean[]>(i));
    tot=new And<>(evch,tot);
  }
  SAFA<Integer,boolean[]> safa2=tot.getSAFA(ba);
  long startTime=System.currentTimeMillis();
  boolean b=true;
  try {
    b=SAFA.isEquivalent(safa1,safa2,ba,SumOfProductsFactory.getInstance()).first;
  }
 catch (  TimeoutException toe) {
    System.out.println(toe);
  }
  long stopTime=System.currentTimeMillis();
  long elapsedTime=stopTime - startTime;
  System.out.println(elapsedTime);
  startTime=System.currentTimeMillis();
  Pair<Boolean,List<boolean[]>> b1=SAFA.areReverseEquivalent(safa1,safa2,ba);
  System.out.println(b1);
  stopTime=System.currentTimeMillis();
  elapsedTime=stopTime - startTime;
  System.out.println(elapsedTime);
  assertTrue(b == b1.first);
}
Program: 42210
Project: 42210
Buggy source:
@Test public void testNegate() throws TimeoutException {
  SAFA<CharPred,Character> a=atLeastOneAlpha.intersectionWith(atLeastOneNum,ba);
  SAFA<CharPred,Character> b=atLeastOneNum.intersectionWith(atLeastOneAlpha,ba);
  SAFA<CharPred,Character> notA=a.negate(ba);
  SAFA<CharPred,Character> notB=b.negate(ba);
  BooleanExpressionFactory<SumOfProducts> boolexpr=SumOfProductsFactory.getInstance();
  assertTrue(SAFA.isEmpty(a.intersectionWith(notA,ba),ba));
  assertTrue(SAFA.isEmpty(b.intersectionWith(notB,ba),ba));
  assertTrue(SAFA.isEquivalent(a,notA.negate(ba),ba,boolexpr));
  assertTrue(SAFA.isEquivalent(a,notB.negate(ba),ba,boolexpr));
}

Fixed version (ground truth):
@Test public void testNegate() throws TimeoutException {
  SAFA<CharPred,Character> a=atLeastOneAlpha.intersectionWith(atLeastOneNum,ba);
  SAFA<CharPred,Character> b=atLeastOneNum.intersectionWith(atLeastOneAlpha,ba);
  SAFA<CharPred,Character> notA=a.negate(ba);
  SAFA<CharPred,Character> notB=b.negate(ba);
  BooleanExpressionFactory<SumOfProducts> boolexpr=SumOfProductsFactory.getInstance();
  assertTrue(SAFA.isEmpty(a.intersectionWith(notA,ba),ba));
  assertTrue(SAFA.isEmpty(b.intersectionWith(notB,ba),ba));
  assertTrue(SAFA.isEquivalent(a,notA.negate(ba),ba,boolexpr).first);
  assertTrue(SAFA.isEquivalent(a,notB.negate(ba),ba,boolexpr).first);
}
Program: 42211
Project: 42211
Buggy source:
@Test public void testForwardEquivalence() throws TimeoutException {
  BooleanExpressionFactory<SumOfProducts> pos=SumOfProductsFactory.getInstance();
  SAFA<CharPred,Character> intersection1=atLeastOneAlpha.intersectionWith(atLeastOneNum,ba);
  SAFA<CharPred,Character> intersection2=atLeastOneNum.intersectionWith(atLeastOneAlpha,ba);
  assertFalse(SAFA.isEquivalent(atLeastOneAlpha,atLeastOneNum,ba,pos));
  assertFalse(SAFA.isEquivalent(atLeastOneNum,atLeastOneAlpha,ba,pos));
  assertFalse(SAFA.isEquivalent(atLeastOneAlpha,intersection1,ba,pos));
  assertFalse(SAFA.isEquivalent(intersection1,atLeastOneAlpha,ba,pos));
  assertFalse(SAFA.isEquivalent(atLeastOneAlpha,intersection2,ba,pos));
  assertFalse(SAFA.isEquivalent(intersection2,atLeastOneAlpha,ba,pos));
  assertFalse(SAFA.isEquivalent(atLeastOneNum,intersection1,ba,pos));
  assertFalse(SAFA.isEquivalent(intersection1,atLeastOneNum,ba,pos));
  assertFalse(SAFA.isEquivalent(atLeastOneNum,intersection2,ba,pos));
  assertFalse(SAFA.isEquivalent(intersection2,atLeastOneNum,ba,pos));
  assertTrue(SAFA.isEquivalent(intersection2,intersection1,ba,pos));
  assertTrue(SAFA.isEquivalent(intersection1,intersection2,ba,pos));
}

Fixed version (ground truth):
@Test public void testForwardEquivalence() throws TimeoutException {
  BooleanExpressionFactory<SumOfProducts> pos=SumOfProductsFactory.getInstance();
  SAFA<CharPred,Character> intersection1=atLeastOneAlpha.intersectionWith(atLeastOneNum,ba);
  SAFA<CharPred,Character> intersection2=atLeastOneNum.intersectionWith(atLeastOneAlpha,ba);
  assertFalse(SAFA.isEquivalent(atLeastOneAlpha,atLeastOneNum,ba,pos).first);
  assertFalse(SAFA.isEquivalent(atLeastOneNum,atLeastOneAlpha,ba,pos).first);
  assertFalse(SAFA.isEquivalent(atLeastOneAlpha,intersection1,ba,pos).first);
  assertFalse(SAFA.isEquivalent(intersection1,atLeastOneAlpha,ba,pos).first);
  assertFalse(SAFA.isEquivalent(atLeastOneAlpha,intersection2,ba,pos).first);
  assertFalse(SAFA.isEquivalent(intersection2,atLeastOneAlpha,ba,pos).first);
  assertFalse(SAFA.isEquivalent(atLeastOneNum,intersection1,ba,pos).first);
  assertFalse(SAFA.isEquivalent(intersection1,atLeastOneNum,ba,pos).first);
  assertFalse(SAFA.isEquivalent(atLeastOneNum,intersection2,ba,pos).first);
  assertFalse(SAFA.isEquivalent(intersection2,atLeastOneNum,ba,pos).first);
  assertTrue(SAFA.isEquivalent(intersection2,intersection1,ba,pos).first);
  assertTrue(SAFA.isEquivalent(intersection1,intersection2,ba,pos).first);
}
Program: 42212
Project: 42212
Buggy source:
public static void RunSelfEquivLTLFile(Path filePath,TestThread tt) throws IOException {
  List<LTLNode> nodes=LTLParserProvider.parse(new FileReader(filePath.toFile()));
  for (  LTLNode ltl : nodes) {
    Pair<BDDSolver,LTLFormula<BDD,BDD>> pair=LTLConverter.getLTLBDD(ltl);
    BDDSolver bdds=pair.first;
    LTLFormula<BDD,BDD> tot=pair.second.pushNegations(bdds);
    SAFA<BDD,BDD> safa=tot.getSAFA(bdds);
    if (tt.isRunning) {
      long startTime=System.currentTimeMillis();
      boolean b=true;
      long stopTime=System.currentTimeMillis();
      try {
        b=SAFA.isEquivalent(safa,safa,bdds,SumOfProductsFactory.getInstance());
        stopTime=System.currentTimeMillis();
      }
 catch (      TimeoutException toe) {
        stopTime=System.currentTimeMillis() + timeout;
      }
      if (tt.isRunning) {
        long elapsedTime=stopTime - startTime;
        System.out.println(elapsedTime);
        startTime=System.currentTimeMillis();
        Pair<Boolean,List<BDD>> b1=SAFA.areReverseEquivalent(safa,safa,bdds);
        if (tt.isRunning) {
          stopTime=System.currentTimeMillis();
          elapsedTime=stopTime - startTime;
          System.out.println(elapsedTime);
          if (b != b1.first)           throw new IllegalArgumentException("String_Node_Str");
        }
      }
    }
  }
}

Fixed version (ground truth):
public static void RunSelfEquivLTLFile(Path filePath,TestThread tt) throws IOException {
  List<LTLNode> nodes=LTLParserProvider.parse(new FileReader(filePath.toFile()));
  for (  LTLNode ltl : nodes) {
    Pair<BDDSolver,LTLFormula<BDD,BDD>> pair=LTLConverter.getLTLBDD(ltl);
    BDDSolver bdds=pair.first;
    LTLFormula<BDD,BDD> tot=pair.second.pushNegations(bdds);
    SAFA<BDD,BDD> safa=tot.getSAFA(bdds);
    if (tt.isRunning) {
      long startTime=System.currentTimeMillis();
      boolean b=true;
      long stopTime=System.currentTimeMillis();
      try {
        b=SAFA.isEquivalent(safa,safa,bdds,SumOfProductsFactory.getInstance()).getFirst();
        stopTime=System.currentTimeMillis();
      }
 catch (      TimeoutException toe) {
        stopTime=System.currentTimeMillis() + timeout;
      }
      if (tt.isRunning) {
        long elapsedTime=stopTime - startTime;
        System.out.println(elapsedTime);
        startTime=System.currentTimeMillis();
        Pair<Boolean,List<BDD>> b1=SAFA.areReverseEquivalent(safa,safa,bdds);
        if (tt.isRunning) {
          stopTime=System.currentTimeMillis();
          elapsedTime=stopTime - startTime;
          System.out.println(elapsedTime);
          if (b != b1.first)           throw new IllegalArgumentException("String_Node_Str");
        }
      }
    }
  }
}
Program: 42214
Project: 42214
Buggy source:
public SAFA<P,S,E> negate(BooleanAlgebra<P,S> ba,BooleanExpressionFactory<E> boolexpr){
class DeMorgan extends BooleanExpressionFactory<E> {
    public DeMorgan(){
    }
    public E MkAnd(    E p,    E q){
      return boolexpr.MkOr(p,q);
    }
    public E MkOr(    E p,    E q){
      return boolexpr.MkAnd(p,q);
    }
    public E True(){
      return boolexpr.False();
    }
    public E False(){
      return boolexpr.True();
    }
    public E MkState(    int i){
      return boolexpr.MkState(i);
    }
  }
  Collection<SAFAInputMove<P,S,E>> transitions=new ArrayList<SAFAInputMove<P,S,E>>();
  BooleanExpressionMorphism<E> demorganize=new BooleanExpressionMorphism<E>((x) -> boolexpr.MkState(x),new DeMorgan());
  for (int state=0; state < maxStateId; state++) {
    if (!inputMovesFrom.containsKey(state)) {
      continue;
    }
    for (    SAFAInputMove<P,S,E> transition : inputMovesFrom.get(state)) {
      transitions.add(new SAFAInputMove<>(state,demorganize.apply(transition.to),transition.guard));
    }
  }
  Set<Integer> nonFinal=new HashSet<>();
  for (int state=0; state < maxStateId; state++) {
    if (!finalStates.contains(state)) {
      nonFinal.add(state);
    }
  }
  return MkSAFA(transitions,initialState,nonFinal,ba,boolexpr,true);
}

Fixed version (ground truth):
/** 
 * Computes the complement of the automaton as a new SAFA.  The input automaton need not be normal.
 */
public SAFA<P,S,E> negate(BooleanAlgebra<P,S> ba,BooleanExpressionFactory<E> boolexpr){
class DeMorgan extends BooleanExpressionFactory<E> {
    public DeMorgan(){
    }
    public E MkAnd(    E p,    E q){
      return boolexpr.MkOr(p,q);
    }
    public E MkOr(    E p,    E q){
      return boolexpr.MkAnd(p,q);
    }
    public E True(){
      return boolexpr.False();
    }
    public E False(){
      return boolexpr.True();
    }
    public E MkState(    int i){
      return boolexpr.MkState(i);
    }
  }
  Collection<SAFAInputMove<P,S,E>> transitions=new ArrayList<SAFAInputMove<P,S,E>>();
  BooleanExpressionMorphism<E> demorganize=new BooleanExpressionMorphism<E>((x) -> boolexpr.MkState(x),new DeMorgan());
  boolean addAccept=false;
  for (int state=0; state <= maxStateId; state++) {
    P residual=ba.True();
    if (inputMovesFrom.containsKey(state)) {
      for (      SAFAInputMove<P,S,E> transition : inputMovesFrom.get(state)) {
        transitions.add(new SAFAInputMove<>(state,demorganize.apply(transition.to),transition.guard));
        residual=ba.MkAnd(ba.MkNot(transition.guard),residual);
      }
    }
    if (ba.IsSatisfiable(residual)) {
      transitions.add(new SAFAInputMove(state,boolexpr.MkState(maxStateId + 1),residual));
      addAccept=true;
    }
  }
  Set<Integer> nonFinal=new HashSet<>();
  for (int state=0; state <= maxStateId; state++) {
    if (!finalStates.contains(state)) {
      nonFinal.add(state);
    }
  }
  if (addAccept) {
    nonFinal.add(maxStateId + 1);
    transitions.add(new SAFAInputMove<>(maxStateId + 1,boolexpr.MkState(maxStateId + 1),ba.True()));
  }
  E notInitial=demorganize.apply(initialState);
  return MkSAFA(transitions,notInitial,nonFinal,ba,boolexpr,false);
}
Program: 42215
Project: 42215
Buggy source:
@Test public void testNegate() throws TimeoutException {
  SAFA<CharPred,Character,SumOfProducts> intersection1=atLeastOneAlpha.intersectionWith(atLeastOneNum,ba,boolexpr);
  SAFA<CharPred,Character,SumOfProducts> intersection2=atLeastOneNum.intersectionWith(atLeastOneAlpha,ba,boolexpr);
  SAFA<CharPred,Character,SumOfProducts> notIntersection1=intersection1.negate(ba,boolexpr);
  SAFA<CharPred,Character,SumOfProducts> notIntersection2=intersection2.negate(ba,boolexpr);
  assertTrue(SAFA.isEmpty(intersection1.intersectionWith(notIntersection1,ba,boolexpr),ba,boolexpr));
  assertTrue(SAFA.isEmpty(intersection2.intersectionWith(notIntersection2,ba,boolexpr),ba,boolexpr));
  assertTrue(SAFA.isEquivalent(intersection1,notIntersection1.negate(ba,boolexpr),ba,boolexpr));
  assertTrue(SAFA.isEquivalent(intersection2,notIntersection2.negate(ba,boolexpr),ba,boolexpr));
}

Fixed version (ground truth):
@Test public void testNegate() throws TimeoutException {
  SAFA<CharPred,Character,SumOfProducts> a=atLeastOneAlpha.intersectionWith(atLeastOneNum,ba,boolexpr);
  SAFA<CharPred,Character,SumOfProducts> b=atLeastOneNum.intersectionWith(atLeastOneAlpha,ba,boolexpr);
  SAFA<CharPred,Character,SumOfProducts> notA=a.negate(ba,boolexpr);
  SAFA<CharPred,Character,SumOfProducts> notB=b.negate(ba,boolexpr);
  assertTrue(SAFA.isEmpty(a.intersectionWith(notA,ba,boolexpr),ba,boolexpr));
  assertTrue(SAFA.isEmpty(b.intersectionWith(notB,ba,boolexpr),ba,boolexpr));
  assertTrue(SAFA.isEquivalent(a,notA.negate(ba,boolexpr),ba,boolexpr));
  assertTrue(SAFA.isEquivalent(a,notB.negate(ba,boolexpr),ba,boolexpr));
}
Program: 42217
Project: 42217
Buggy source:
/** 
 * Returns true if the SAFA accepts the input list
 * @param input
 * @param ba
 * @return true if accepted false otherwise
 */
public boolean accepts(List<S> input,BooleanAlgebra<P,S> ba){
  List<S> revInput=Lists.reverse(input);
  Collection<Integer> currConf=finalStates;
  for (  S el : revInput) {
    currConf=getPrevState(currConf,el,ba);
    if (currConf.isEmpty())     return false;
  }
  return currConf.contains(initialState);
}

Fixed version (ground truth):
/** 
 * Returns true if the SAFA accepts the input list
 * @param input
 * @param ba
 * @return true if accepted false otherwise
 */
public boolean accepts(List<S> input,BooleanAlgebra<P,S> ba){
  List<S> revInput=Lists.reverse(input);
  Collection<Integer> currConf=finalStates;
  for (  S el : revInput) {
    currConf=getPrevState(currConf,el,ba);
    if (currConf.isEmpty())     return false;
  }
  return initialState.hasModel(currConf);
}
Program: 42218
Project: 42218
Buggy source:
public Integer MkAnd(Integer left,Integer right){
  List<Integer> conjuncts=new LinkedList<>();
  conjuncts.add(left);
  conjuncts.add(right);
  return MkAnd(conjuncts);
}

Fixed version (ground truth):
public Integer MkAnd(Integer left,Integer right){
  Set<Integer> conjuncts=new TreeSet<>();
  conjuncts.add(left);
  conjuncts.add(right);
  return MkAnd(conjuncts);
}
Program: 42219
Project: 42219
Buggy source:
/** 
 * Normalizes the SAFA by having at most one transition for each symbol out of each state
 */
public SAFA<P,S,E> normalize(BooleanAlgebra<P,S> ba,BooleanExpressionFactory<E> boolexpr){
  Collection<SAFAInputMove<P,S,E>> transitions=new ArrayList<SAFAInputMove<P,S,E>>();
  boolean addedSink=false;
  int sink=maxStateId + 1;
  for (  int state : states) {
    ArrayList<SAFAInputMove<P,S,E>> trFromState=new ArrayList<>(getInputMovesFrom(state));
    P leftoverPredicate=ba.True();
    ArrayList<P> predicates=new ArrayList<>();
    for (    SAFAInputMove<P,S,E> t : trFromState) {
      predicates.add(t.guard);
      ba.MkAnd(leftoverPredicate,ba.MkNot(t.guard));
    }
    if (ba.IsSatisfiable(leftoverPredicate)) {
      transitions.add(new SAFAInputMove<>(state,boolexpr.MkState(sink),leftoverPredicate));
      addedSink=true;
    }
    Collection<Pair<P,ArrayList<Integer>>> minterms=ba.GetMinterms(predicates);
    for (    Pair<P,ArrayList<Integer>> minterm : minterms) {
      E newTo=null;
      for (int i=0; i < minterm.second.size(); i++)       if (minterm.second.get(i) == 1)       if (newTo == null)       newTo=trFromState.get(i).to;
 else       newTo=boolexpr.MkOr(newTo,trFromState.get(i).to);
      if (newTo != null)       transitions.add(new SAFAInputMove<>(state,newTo,minterm.first));
    }
  }
  if (addedSink)   transitions.add(new SAFAInputMove<>(sink,boolexpr.MkState(sink),ba.True()));
  return MkSAFA(transitions,initialState,finalStates,ba,boolexpr,false);
}

Fixed version (ground truth):
/** 
 * Normalizes the SAFA by having at most one transition for each symbol out of each state
 */
public SAFA<P,S,E> normalize(BooleanAlgebra<P,S> ba,BooleanExpressionFactory<E> boolexpr){
  Collection<SAFAInputMove<P,S,E>> transitions=new ArrayList<SAFAInputMove<P,S,E>>();
  boolean addedSink=false;
  int sink=maxStateId + 1;
  for (  int state : states) {
    ArrayList<SAFAInputMove<P,S,E>> trFromState=new ArrayList<>(getInputMovesFrom(state));
    ArrayList<P> predicates=new ArrayList<>();
    for (    SAFAInputMove<P,S,E> t : trFromState) {
      predicates.add(t.guard);
    }
    Collection<Pair<P,ArrayList<Integer>>> minterms=ba.GetMinterms(predicates);
    for (    Pair<P,ArrayList<Integer>> minterm : minterms) {
      E newTo=null;
      for (int i=0; i < minterm.second.size(); i++)       if (minterm.second.get(i) == 1)       if (newTo == null)       newTo=trFromState.get(i).to;
 else       newTo=boolexpr.MkOr(newTo,trFromState.get(i).to);
      if (newTo != null) {
        transitions.add(new SAFAInputMove<>(state,newTo,minterm.first));
      }
 else {
        transitions.add(new SAFAInputMove<>(state,boolexpr.MkState(sink),minterm.first));
        addedSink=true;
      }
    }
  }
  if (addedSink)   transitions.add(new SAFAInputMove<>(sink,boolexpr.MkState(sink),ba.True()));
  return MkSAFA(transitions,initialState,finalStates,ba,boolexpr,false);
}
Program: 42221
Project: 42221
Buggy source:
public boolean mergeSets(int elemIndex0,int elemIndex1){
  int repr0=getRepr(elemIndex0);
  int repr1=getRepr(elemIndex1);
  if (repr0 == repr1)   return false;
  int cmp=ranks[repr0] - ranks[repr1];
  if (cmp == 0)   ranks[repr0]++;
 else   if (cmp < 0) {
    int temp=repr0;
    repr0=repr1;
    repr1=temp;
  }
  parents[repr1]=repr0;
  sizes[repr0]+=sizes[repr1];
  sizes[repr1]=0;
  numSets--;
  return true;
}

Fixed version (ground truth):
public boolean mergeSets(int elemIndex0,int elemIndex1){
  int repr0=getRepr(elemIndex0);
  int repr1=getRepr(elemIndex1);
  if (repr0 == repr1)   return false;
  int cmp=ranks.get(repr0) - ranks.get(repr1);
  if (cmp == 0) {
    int r=ranks.get(repr0);
    ranks.put(repr0,r + 1);
  }
 else   if (cmp < 0) {
    int temp=repr0;
    repr0=repr1;
    repr1=temp;
  }
  parents.put(repr1,repr0);
  int sizer1=sizes.get(repr1);
  sizes.put(repr0,sizer1);
  sizes.put(repr1,0);
  numSets--;
  return true;
}
Program: 42222
Project: 42222
Buggy source:
void checkStructure(){
  int numRepr=0;
  for (int i=0; i < parents.length; i++) {
    int parent=parents[i];
    int rank=ranks[i];
    int size=sizes[i];
    boolean isRepr=parent == i;
    if (isRepr)     numRepr++;
    boolean ok=true;
    ok&=0 <= parent && parent < parents.length;
    ok&=0 <= rank && (isRepr || rank < ranks[parent]);
    ok&=!isRepr && size == 0 || isRepr && size >= (1 << rank);
    if (!ok)     throw new AssertionError();
  }
  if (!(1 <= numSets && numSets == numRepr && numSets <= parents.length))   throw new AssertionError();
}

Fixed version (ground truth):
void checkStructure(){
  int numRepr=0;
  for (int i=0; i < parents.size(); i++) {
    int parent=parents.get(i);
    int rank=ranks.get(i);
    int size=sizes.get(i);
    boolean isRepr=parent == i;
    if (isRepr)     numRepr++;
    boolean ok=true;
    ok&=0 <= parent && parent < parents.size();
    ok&=0 <= rank && (isRepr || rank < ranks.get(parent));
    ok&=!isRepr && size == 0 || isRepr && size >= (1 << rank);
    if (!ok)     throw new AssertionError();
  }
  if (!(1 <= numSets && numSets == numRepr && numSets <= parents.size()))   throw new AssertionError();
}
Program: 42223
Project: 42223
Buggy source:
public int getSizeOfSet(int elemIndex){
  return sizes[getRepr(elemIndex)];
}

Fixed version (ground truth):
public int getSizeOfSet(int elemIndex){
  return sizes.get(getRepr(elemIndex));
}
Program: 42224
Project: 42224
Buggy source:
public int getNumberOfElements(){
  return parents.length;
}

Fixed version (ground truth):
public int getNumberOfElements(){
  return parents.size();
}
Program: 42225
Project: 42225
Buggy source:
public DisjointSet(int numElems){
  if (numElems <= 0)   throw new IllegalArgumentException("String_Node_Str");
  parents=new int[numElems];
  ranks=new byte[numElems];
  sizes=new int[numElems];
  for (int i=0; i < numElems; i++) {
    parents[i]=i;
    ranks[i]=0;
    sizes[i]=1;
  }
  numSets=numElems;
}

Fixed version (ground truth):
public DisjointSet(){
  parents=new HashMap<>();
  ranks=new HashMap<>();
  sizes=new HashMap<>();
  numSets=0;
}
Program: 42226
Project: 42226
Buggy source:
public int getRepr(int elemIndex){
  if (elemIndex < 0 || elemIndex >= parents.length)   throw new IndexOutOfBoundsException();
  int parent=parents[elemIndex];
  if (parent == elemIndex)   return elemIndex;
  while (true) {
    int grandparent=parents[parent];
    if (grandparent == parent)     return parent;
    parents[elemIndex]=grandparent;
    elemIndex=parent;
    parent=grandparent;
  }
}

Fixed version (ground truth):
public int getRepr(int elemIndex){
  int parent=parents.get(elemIndex);
  if (parent == elemIndex)   return elemIndex;
  while (true) {
    int grandparent=parents.get(parent);
    if (grandparent == parent)     return parent;
    parents.put(elemIndex,grandparent);
    elemIndex=parent;
    parent=grandparent;
  }
}
Program: 42227
Project: 42227
Buggy source:
/** 
 * Returns the empty SST
 */
public static <P1,F1,S1>SST<P1,F1,S1> getEmptySST(BooleanAlgebraSubst<P1,F1,S1> ba){
  SST<P1,F1,S1> aut=new SST<P1,F1,S1>();
  aut.states=new HashSet<Integer>();
  aut.states.add(0);
  aut.initialState=0;
  aut.isDeterministic=true;
  aut.isEmpty=true;
  aut.isEpsilonFree=true;
  aut.maxStateId=1;
  return aut;
}

Fixed version (ground truth):
/** 
 * Returns the empty SST
 */
public static <P1,F1,S1>SST<P1,F1,S1> getEmptySST(BooleanAlgebraSubst<P1,F1,S1> ba){
  SST<P1,F1,S1> aut=new SST<P1,F1,S1>();
  aut.states=new HashSet<Integer>();
  aut.states.add(0);
  aut.initialState=0;
  aut.isDeterministic=true;
  aut.isEmpty=true;
  aut.variableCount=0;
  aut.isEpsilonFree=true;
  aut.maxStateId=1;
  return aut;
}
Program: 42229
Project: 42229
Buggy source:
/** 
 * @return a new total total SFA (with one transition for each symbol out ofevery state) equivalent to <code>aut</code>
 */
@SuppressWarnings("String_Node_Str") public static <A,B>SFA<A,B> mkTotal(SFA<A,B> aut,BooleanAlgebra<A,B> ba){
  if (aut.isTotal) {
    return (SFA<A,B>)aut.clone();
  }
  SFA<A,B> sfa=aut;
  if (!aut.isDeterministic(ba))   sfa=determinize(aut,ba);
  Collection<SFAMove<A,B>> transitions=new ArrayList<SFAMove<A,B>>();
  Integer initialState=sfa.initialState;
  Collection<Integer> finalStates=new HashSet<Integer>(sfa.finalStates);
  int sinkState=sfa.maxStateId + 1;
  boolean addSink=false;
  for (  Integer state : sfa.states) {
    A totGuard=null;
    for (    SFAInputMove<A,B> move : sfa.getInputMovesFrom(state)) {
      transitions.add(move);
      if (totGuard == null)       totGuard=ba.MkNot(move.guard);
 else       totGuard=ba.MkAnd(totGuard,ba.MkNot(move.guard));
    }
    if (totGuard != null && ba.IsSatisfiable(totGuard)) {
      addSink=true;
      transitions.add(new SFAInputMove<A,B>(state,sinkState,totGuard));
    }
  }
  if (addSink)   transitions.add(new SFAInputMove<A,B>(sinkState,sinkState,ba.True()));
  return MkSFA(transitions,initialState,finalStates,ba,false);
}

Fixed version (ground truth):
/** 
 * @return a new total total SFA (with one transition for each symbol out ofevery state) equivalent to <code>aut</code>
 */
@SuppressWarnings("String_Node_Str") public static <A,B>SFA<A,B> mkTotal(SFA<A,B> aut,BooleanAlgebra<A,B> ba){
  if (aut.isTotal) {
    return (SFA<A,B>)aut.clone();
  }
  SFA<A,B> sfa=aut;
  if (!aut.isDeterministic(ba))   sfa=determinize(aut,ba);
  Collection<SFAMove<A,B>> transitions=new ArrayList<SFAMove<A,B>>();
  Integer initialState=sfa.initialState;
  Collection<Integer> finalStates=new HashSet<Integer>(sfa.finalStates);
  int sinkState=sfa.maxStateId + 1;
  boolean addSink=false;
  for (  Integer state : sfa.states) {
    A totGuard=null;
    for (    SFAInputMove<A,B> move : sfa.getInputMovesFrom(state)) {
      transitions.add(move);
      if (totGuard == null)       totGuard=ba.MkNot(move.guard);
 else       totGuard=ba.MkAnd(totGuard,ba.MkNot(move.guard));
    }
    if (totGuard == null)     totGuard=ba.True();
    if (ba.IsSatisfiable(totGuard)) {
      addSink=true;
      transitions.add(new SFAInputMove<A,B>(state,sinkState,totGuard));
    }
  }
  if (addSink)   transitions.add(new SFAInputMove<A,B>(sinkState,sinkState,ba.True()));
  return MkSFA(transitions,initialState,finalStates,ba,false);
}
Program: 42230
Project: 42230
Buggy source:
private static <A,B>SFA<A,B> MkSFA(Collection<SFAMove<A,B>> transitions,Integer initialState,Collection<Integer> finalStates,BooleanAlgebra<A,B> ba,boolean remUnreachableStates,boolean normalize){
  SFA<A,B> aut=new SFA<A,B>();
  aut.states=new HashSet<Integer>();
  aut.states.add(initialState);
  aut.states.addAll(finalStates);
  aut.initialState=initialState;
  aut.finalStates=finalStates;
  for (  SFAMove<A,B> t : transitions)   aut.addTransition(t,ba,false);
  if (normalize)   aut=aut.normalize(ba);
  if (remUnreachableStates)   aut=removeDeadOrUnreachableStates(aut,ba);
  return aut;
}

Fixed version (ground truth):
private static <A,B>SFA<A,B> MkSFA(Collection<SFAMove<A,B>> transitions,Integer initialState,Collection<Integer> finalStates,BooleanAlgebra<A,B> ba,boolean remUnreachableStates,boolean normalize){
  SFA<A,B> aut=new SFA<A,B>();
  aut.states=new HashSet<Integer>();
  aut.states.add(initialState);
  aut.states.addAll(finalStates);
  aut.initialState=initialState;
  aut.finalStates=finalStates;
  if (finalStates.isEmpty())   return getEmptySFA(ba);
  for (  SFAMove<A,B> t : transitions)   aut.addTransition(t,ba,false);
  if (normalize)   aut=aut.normalize(ba);
  if (remUnreachableStates)   aut=removeDeadOrUnreachableStates(aut,ba);
  if (aut.finalStates.isEmpty())   return getEmptySFA(ba);
  return aut;
}
Program: 42231
Project: 42231
Buggy source:
public char instantiateWith(char c){
  return (char)(c + increment);
}

Fixed version (ground truth):
public char instantiateWith(char c){
  return (char)charSnap(c + increment);
}
Program: 42232
Project: 42232
Buggy source:
public CharPred substIn(CharPred p,CharSolver cs){
  ImmutableList.Builder<ImmutablePair<Character,Character>> intervals=ImmutableList.builder();
  for (  ImmutablePair<Character,Character> interval : checkNotNull(p).intervals) {
    intervals.add(ImmutablePair.of((char)(interval.left - increment),(char)(interval.right - increment)));
  }
  return new CharPred(intervals.build());
}

Fixed version (ground truth):
public CharPred substIn(CharPred p,CharSolver cs){
  ImmutableList.Builder<ImmutablePair<Character,Character>> intervals=ImmutableList.builder();
  for (  ImmutablePair<Character,Character> interval : checkNotNull(p).intervals) {
    long leftPrime=charSnap(interval.left - increment);
    long rightPrime=charSnap(interval.right - increment);
    intervals.add(ImmutablePair.of((char)leftPrime,(char)rightPrime));
  }
  return new CharPred(intervals.build());
}
Program: 42234
Project: 42234
Buggy source:
public RequestTrackerBundle(){
  this.header=RequestTrackerConstants.DEFAULT_LOG_ID_HEADER;
}

Fixed version (ground truth):
public RequestTrackerBundle(){
  this.header=RequestTrackerConstants.DEFAULT_HEADER;
}
Program: 42235
Project: 42235
Buggy source:
protected ClientRequest doWork(ClientRequest clientRequest){
  Optional<String> requestId=Optional.fromNullable(MDC.get(RequestTrackerConstants.MDC_KEY));
  clientRequest.getHeaders().add(header,requestId.or(ID_SUPPLIER));
  return clientRequest;
}

Fixed version (ground truth):
protected ClientRequest doWork(ClientRequest clientRequest){
  Optional<String> requestId=Optional.fromNullable(MDC.get(RequestTrackerConstants.DEFAULT_MDC_KEY));
  clientRequest.getHeaders().add(header,requestId.or(ID_SUPPLIER));
  return clientRequest;
}
Program: 42236
Project: 42236
Buggy source:
public RequestTrackerClientFilter(){
  this.header=RequestTrackerConstants.DEFAULT_LOG_ID_HEADER;
}

Fixed version (ground truth):
public RequestTrackerClientFilter(){
  this.header=RequestTrackerConstants.DEFAULT_HEADER;
}
Program: 42237
Project: 42237
Buggy source:
@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  HttpServletRequest httpServletRequest=(HttpServletRequest)request;
  Optional<String> requestId=Optional.fromNullable(httpServletRequest.getHeader(header));
  MDC.put(RequestTrackerConstants.MDC_KEY,requestId.or(ID_SUPPLIER));
  chain.doFilter(request,response);
}

Fixed version (ground truth):
@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  HttpServletRequest httpServletRequest=(HttpServletRequest)request;
  Optional<String> requestId=Optional.fromNullable(httpServletRequest.getHeader(header));
  MDC.put(RequestTrackerConstants.DEFAULT_MDC_KEY,requestId.or(ID_SUPPLIER));
  chain.doFilter(request,response);
}
Program: 42238
Project: 42238
Buggy source:
public RequestTrackerServletFilter(){
  this.header=RequestTrackerConstants.DEFAULT_LOG_ID_HEADER;
}

Fixed version (ground truth):
public RequestTrackerServletFilter(){
  this.header=RequestTrackerConstants.DEFAULT_HEADER;
}
Program: 42239
Project: 42239
Buggy source:
@Test public void usesExistingMDCValueWhenPresent(){
  String logId=UUID.randomUUID().toString();
  MDC.put(RequestTrackerConstants.MDC_KEY,logId);
  requestTrackerClientFilter.doWork(clientRequest);
  verify(headersMap).add(eq(RequestTrackerConstants.DEFAULT_LOG_ID_HEADER),eq(logId));
}

Fixed version (ground truth):
@Test public void usesExistingMDCValueWhenPresent(){
  String logId=UUID.randomUUID().toString();
  MDC.put(RequestTrackerConstants.DEFAULT_MDC_KEY,logId);
  requestTrackerClientFilter.doWork(clientRequest);
  verify(headersMap).add(eq(RequestTrackerConstants.DEFAULT_HEADER),eq(logId));
}
Program: 42240
Project: 42240
Buggy source:
@Test public void setsTheRequestTrackerHeader(){
  requestTrackerClientFilter.doWork(clientRequest);
  verify(headersMap).add(eq(RequestTrackerConstants.DEFAULT_LOG_ID_HEADER),Mockito.any(UUID.class));
}

Fixed version (ground truth):
@Test public void setsTheRequestTrackerHeader(){
  requestTrackerClientFilter.doWork(clientRequest);
  verify(headersMap).add(eq(RequestTrackerConstants.DEFAULT_HEADER),Mockito.any(UUID.class));
}
Program: 42241
Project: 42241
Buggy source:
@Test public void reusesIdWhenHeaderPresent() throws Exception {
  String headerId=UUID.randomUUID().toString();
  when(request.getHeader(RequestTrackerConstants.DEFAULT_LOG_ID_HEADER)).thenReturn(headerId);
  requestTrackerServletFilter.doFilter(request,response,chain);
  String idInLog=MDC.get(RequestTrackerConstants.MDC_KEY);
  assertThat(idInLog,equalTo(headerId));
}

Fixed version (ground truth):
@Test public void reusesIdWhenHeaderPresent() throws Exception {
  String headerId=UUID.randomUUID().toString();
  when(request.getHeader(RequestTrackerConstants.DEFAULT_HEADER)).thenReturn(headerId);
  requestTrackerServletFilter.doFilter(request,response,chain);
  String idInLog=MDC.get(RequestTrackerConstants.DEFAULT_MDC_KEY);
  assertThat(idInLog,equalTo(headerId));
}
Program: 42242
Project: 42242
Buggy source:
@Test public void checksForHeader() throws Exception {
  requestTrackerServletFilter.doFilter(request,response,chain);
  verify(request).getHeader(RequestTrackerConstants.DEFAULT_LOG_ID_HEADER);
}

Fixed version (ground truth):
@Test public void checksForHeader() throws Exception {
  requestTrackerServletFilter.doFilter(request,response,chain);
  verify(request).getHeader(RequestTrackerConstants.DEFAULT_HEADER);
}
Program: 42243
Project: 42243
Buggy source:
@Test public void setsIdWhenHeaderMissing() throws Exception {
  requestTrackerServletFilter.doFilter(request,response,chain);
  UUID.fromString(MDC.get(RequestTrackerConstants.MDC_KEY));
}

Fixed version (ground truth):
@Test public void setsIdWhenHeaderMissing() throws Exception {
  requestTrackerServletFilter.doFilter(request,response,chain);
  UUID.fromString(MDC.get(RequestTrackerConstants.DEFAULT_MDC_KEY));
}
Program: 42244
Project: 42244
Buggy source:
@Test public void addsTrackerToOutgoingRequest() throws Exception {
  Client client=new Client();
  client.addFilter(new RequestTrackerClientFilter("String_Node_Str"));
  URI initialURI=new URI("String_Node_Str",null,"String_Node_Str",RULE.getLocalPort(),"String_Node_Str",null,null);
  URI secondaryURI=new URI("String_Node_Str",null,"String_Node_Str",RULE.getLocalPort(),"String_Node_Str",null,null);
  ClientTestResource clientTest=new ClientTestResource(secondaryURI,client);
  MockTestResource mockTest=new MockTestResource();
  RULE.getEnvironment().getApplicationContext().stop();
  RULE.getEnvironment().jersey().register(mockTest);
  RULE.getEnvironment().jersey().register(clientTest);
  RULE.getEnvironment().getApplicationContext().start();
  client.resource(initialURI).post(ClientResponse.class);
  assertThat(mockTest.getHeaders().getRequestHeader("String_Node_Str"),notNullValue());
  assertThat(mockTest.getHeaders().getRequestHeader(RequestTrackerConstants.DEFAULT_LOG_ID_HEADER),nullValue());
}

Fixed version (ground truth):
@Test public void addsTrackerToOutgoingRequest() throws Exception {
  Client client=new Client();
  client.addFilter(new RequestTrackerClientFilter("String_Node_Str"));
  URI initialURI=new URI("String_Node_Str",null,"String_Node_Str",RULE.getLocalPort(),"String_Node_Str",null,null);
  URI secondaryURI=new URI("String_Node_Str",null,"String_Node_Str",RULE.getLocalPort(),"String_Node_Str",null,null);
  ClientTestResource clientTest=new ClientTestResource(secondaryURI,client);
  MockTestResource mockTest=new MockTestResource();
  RULE.getEnvironment().getApplicationContext().stop();
  RULE.getEnvironment().jersey().register(mockTest);
  RULE.getEnvironment().jersey().register(clientTest);
  RULE.getEnvironment().getApplicationContext().start();
  client.resource(initialURI).post(ClientResponse.class);
  assertThat(mockTest.getHeaders().getRequestHeader("String_Node_Str"),notNullValue());
  assertThat(mockTest.getHeaders().getRequestHeader(RequestTrackerConstants.DEFAULT_HEADER),nullValue());
}
Program: 42245
Project: 42245
Buggy source:
@Test public void keepsTheId() throws Exception {
  Client client=new Client();
  UUID id=UUID.randomUUID();
  client.resource(INITIAL_URI).header(RequestTrackerConstants.DEFAULT_LOG_ID_HEADER,id).post(ClientResponse.class);
  assertThat(MOCK_TEST.getLogId(),equalTo(id.toString()));
}

Fixed version (ground truth):
@Test public void keepsTheId() throws Exception {
  Client client=new Client();
  UUID id=UUID.randomUUID();
  client.resource(INITIAL_URI).header(RequestTrackerConstants.DEFAULT_HEADER,id).post(ClientResponse.class);
  assertThat(MOCK_TEST.getRequestTrackerId(),equalTo(id.toString()));
}
Program: 42246
Project: 42246
Buggy source:
@Test public void addsTrackerToOutgoingRequest() throws Exception {
  CLIENT.resource(INITIAL_URI).post(ClientResponse.class);
  assertThat(MOCK_TEST.getLogId(),notNullValue());
}

Fixed version (ground truth):
@Test public void addsTrackerToOutgoingRequest() throws Exception {
  CLIENT.resource(INITIAL_URI).post(ClientResponse.class);
  assertThat(MOCK_TEST.getRequestTrackerId(),notNullValue());
}
Program: 42247
Project: 42247
Buggy source:
@POST public void test(@Context HttpHeaders headers){
  this.headers=headers;
  this.logId=headers.getRequestHeader(RequestTrackerConstants.DEFAULT_LOG_ID_HEADER).get(0);
}

Fixed version (ground truth):
@POST public void test(@Context HttpHeaders headers){
  this.headers=headers;
  this.requestTrackerId=headers.getRequestHeader(RequestTrackerConstants.DEFAULT_HEADER).get(0);
}
Program: 42248
Project: 42248
Buggy source:
@After public void clear(){
  System.clearProperty(AutomationConstants.AWS_ACCESS_KEY);
  System.clearProperty(AutomationConstants.AWS_PRIVATE_KEY);
}

Fixed version (ground truth):
@After public void clear(){
  System.clearProperty(AutomationConstants.AWS_ACCESS_KEY);
  System.clearProperty(AutomationConstants.AWS_PRIVATE_KEY);
  System.clearProperty("String_Node_Str");
}
Program: 42249
Project: 42249
Buggy source:
@Override public void run(){
  FileOutputStream out;
  try {
    out=new FileOutputStream(fname);
    bitmap.compress(Bitmap.CompressFormat.PNG,80,out);
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void run(){
  FileOutputStream out;
  try {
    out=new FileOutputStream(fname);
    bitmap.compress(Bitmap.CompressFormat.PNG,80,out);
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  IllegalStateException e) {
    e.printStackTrace();
  }
}
Program: 42250
Project: 42250
Buggy source:
public static void outputBitmapToFile(final Bitmap bitmap,final Activity activity){
  String path=Environment.getExternalStorageDirectory().getAbsolutePath() + "String_Node_Str";
  path=path + activity.getPackageName() + "String_Node_Str";
  File dir=new File(path);
  if (!dir.exists()) {
    dir.mkdirs();
  }
  final String fname=path + activity.getLocalClassName() + "String_Node_Str";
  new Thread(){
    @Override public void run(){
      FileOutputStream out;
      try {
        out=new FileOutputStream(fname);
        bitmap.compress(Bitmap.CompressFormat.PNG,80,out);
      }
 catch (      FileNotFoundException e) {
        e.printStackTrace();
      }
    }
  }
.start();
}

Fixed version (ground truth):
public static void outputBitmapToFile(final Bitmap bitmap,final Activity activity){
  String path=Environment.getExternalStorageDirectory().getAbsolutePath() + "String_Node_Str";
  path=path + activity.getPackageName() + "String_Node_Str";
  File dir=new File(path);
  if (!dir.exists()) {
    dir.mkdirs();
  }
  final String fname=path + activity.getLocalClassName() + "String_Node_Str";
  new Thread(){
    @Override public void run(){
      FileOutputStream out;
      try {
        out=new FileOutputStream(fname);
        bitmap.compress(Bitmap.CompressFormat.PNG,80,out);
      }
 catch (      FileNotFoundException e) {
        e.printStackTrace();
      }
catch (      IllegalStateException e) {
        e.printStackTrace();
      }
    }
  }
.start();
}