nus-yam/ex-repair huggingface dataset:
Program: 20420
Project: 20420
Buggy source:
public List<Rule> getRules(BinaryItemSet itemSet,double minCredibility,SortedMap<BinaryItemSet,Integer> frequentSet){
  List<Rule> itemSetRules=new LinkedList<Rule>();
  int suportXY=frequentSet.get(itemSet);
  for (  char elements : itemSet.getAttributeVector()) {
    int count=bitcount(elements);
    if (count == 0 || count == 1)     return itemSetRules;
  }
  Collection<BinaryItemSet> vetoSets=new LinkedList<BinaryItemSet>();
  Collection<BinaryItemSet> nextSets=BinaryItemSet.divideSet(itemSet);
  for (int i=0; i < itemSet.getAttributeVector().length * bitsFactor - 1; i++) {
    List<BinaryItemSet> smallerSets=new LinkedList<BinaryItemSet>(nextSets);
    for (    BinaryItemSet currentSet : smallerSets) {
      int supportX=frequentSet.get(currentSet);
      double confidanceXY=suportXY / supportX;
      if (confidanceXY >= minCredibility) {
        Rule rule=createRuleFromItemSet(itemSet,currentSet,confidanceXY,suportXY);
        itemSetRules.add(rule);
        Collection<BinaryItemSet> sets=BinaryItemSet.divideSet(currentSet);
        if (sets != null)         nextSets.addAll(sets);
      }
 else {
        Collection<BinaryItemSet> sets=BinaryItemSet.divideSet(currentSet);
        if (sets != null)         vetoSets.addAll(sets);
      }
    }
  }
  return itemSetRules;
}

Fixed version (ground truth):
public List<Rule> getRules(BinaryItemSet itemSet,double minCredibility,SortedMap<BinaryItemSet,Integer> frequentSet){
  List<Rule> itemSetRules=new LinkedList<Rule>();
  int suportXY=frequentSet.get(itemSet);
  for (  char elements : itemSet.getAttributeVector()) {
    int count=bitcount(elements);
    if (count == 0 || count == 1)     return itemSetRules;
  }
  Collection<BinaryItemSet> vetoSets=new LinkedList<BinaryItemSet>();
  Collection<BinaryItemSet> nextSets=BinaryItemSet.divideSet(itemSet);
  for (int i=0; i < itemSet.getAttributeVector().length * 16; i++) {
    List<BinaryItemSet> smallerSets=new LinkedList<BinaryItemSet>(nextSets);
    nextSets.clear();
    for (    BinaryItemSet currentSet : smallerSets) {
      int supportX=frequentSet.get(currentSet);
      double confidanceXY=suportXY / (double)supportX;
      if (confidanceXY >= minCredibility) {
        Rule rule=createRuleFromItemSet(itemSet,currentSet,confidanceXY,suportXY);
        itemSetRules.add(rule);
        Collection<BinaryItemSet> sets=BinaryItemSet.divideSet(currentSet);
        if (sets.size() != 0)         nextSets.addAll(sets);
      }
 else {
        Collection<BinaryItemSet> sets=BinaryItemSet.divideSet(currentSet);
        if (sets.size() != 0)         vetoSets.addAll(sets);
      }
    }
  }
  return itemSetRules;
}
Program: 20421
Project: 20421
Buggy source:
public Set<BinaryItemSet> getCandidateSets(Set<BinaryItemSet> frequentSupportMap,int generation){
  Set<BinaryItemSet> output=new TreeSet<BinaryItemSet>();
  for (  BinaryItemSet itemSet : frequentSupportMap) {
    for (    BinaryItemSet singleItemSet : this.levelOneSet) {
      if (itemSet.compareTo(singleItemSet) < 0) {
        char[] vector=itemSet.getAttributeVector();
        char[] singleVector=singleItemSet.getAttributeVector();
        int vectorLength=singleVector.length;
        char[] outputVector=new char[vectorLength];
        for (int i=0; i < vectorLength; i++) {
          outputVector[i]=(char)(vector[i] | singleVector[i]);
        }
        boolean hasSupport=true;
        Collection<BinaryItemSet> items=BinaryItemSet.divideSet(outputVector,generation);
        for (        BinaryItemSet binaryItemSet : items) {
          if (!frequentSupportMap.contains(binaryItemSet)) {
            hasSupport=false;
          }
        }
        if (hasSupport) {
          BinaryItemSet candidate=new BinaryItemSet(outputVector,generation);
          output.add(candidate);
        }
      }
    }
  }
  return output;
}

Fixed version (ground truth):
public Set<BinaryItemSet> getCandidateSets(Set<BinaryItemSet> frequentSupportMap,int generation){
  Set<BinaryItemSet> output=new TreeSet<BinaryItemSet>();
  for (  BinaryItemSet itemSet : frequentSupportMap) {
    for (    BinaryItemSet singleItemSet : this.levelOneSet) {
      if (itemSet.compareTo(singleItemSet) < 0) {
        char[] vector=itemSet.getAttributeVector();
        char[] singleVector=singleItemSet.getAttributeVector();
        int vectorLength=singleVector.length;
        char[] outputVector=new char[vectorLength];
        int sum=0;
        for (int i=0; i < vectorLength; i++) {
          outputVector[i]=(char)(vector[i] | singleVector[i]);
          sum+=BinaryItemSet.bitcount(outputVector[i]);
        }
        if (sum == itemSet.getNumberOfAttributes())         continue;
        boolean hasSupport=true;
        Collection<BinaryItemSet> items=BinaryItemSet.divideSet(outputVector,generation);
        for (        BinaryItemSet binaryItemSet : items) {
          if (!frequentSupportMap.contains(binaryItemSet)) {
            hasSupport=false;
          }
        }
        if (hasSupport) {
          BinaryItemSet candidate=new BinaryItemSet(outputVector,generation);
          output.add(candidate);
        }
      }
    }
  }
  return output;
}
Program: 20422
Project: 20422
Buggy source:
@Test public void get_sample_rules_from_data(){
  char totalVector=32769;
  frequentSet=new BinaryItemSet(new char[]{totalVector});
  frequentSetsMap.put(frequentSet,1);
  BinaryItemSet supportSet1=new BinaryItemSet(new char[]{1});
  BinaryItemSet supportSet2=new BinaryItemSet(new char[]{32768});
  frequentSetsMap.put(supportSet1,2);
  frequentSetsMap.put(supportSet2,2);
  List<Rule> expectedRules=new LinkedList<Rule>();
  List<Integer> listOne=new LinkedList<Integer>();
  listOne.add(1);
  List<Integer> listTwo=new LinkedList<Integer>();
  listOne.add(16);
  expectedRules.add(new Rule(0,listOne,listTwo,1,1));
  expectedRules.add(new Rule(0,listTwo,listOne,1,1));
  List<Rule> result=engine.getRules(frequentSet,0,frequentSetsMap);
  assertLists(expectedRules,result);
}

Fixed version (ground truth):
@Test public void get_sample_rules_from_data(){
  char totalVector=32769;
  frequentSet=new BinaryItemSet(new char[]{totalVector});
  frequentSetsMap.put(frequentSet,1);
  BinaryItemSet supportSet1=new BinaryItemSet(new char[]{1});
  BinaryItemSet supportSet2=new BinaryItemSet(new char[]{32768});
  frequentSetsMap.put(supportSet1,2);
  frequentSetsMap.put(supportSet2,2);
  List<Rule> expectedRules=new LinkedList<Rule>();
  List<Integer> listOne=new LinkedList<Integer>();
  listOne.add(1);
  List<Integer> listTwo=new LinkedList<Integer>();
  listTwo.add(16);
  expectedRules.add(new Rule(1,listOne,listTwo,50,1));
  expectedRules.add(new Rule(0,listTwo,listOne,50,1));
  List<Rule> result=engine.getRules(frequentSet,0,frequentSetsMap);
  assertLists(expectedRules,result);
}
Program: 20423
Project: 20423
Buggy source:
@Test public void set_partition(){
  char chunk1=32769;
  char chunk2=1;
  BinaryItemSet inputSet=new BinaryItemSet(new char[]{chunk1,chunk2},3);
  List<BinaryItemSet> expected=new LinkedList<BinaryItemSet>();
  chunk1=1;
  chunk2=1;
  BinaryItemSet set1=new BinaryItemSet(new char[]{chunk1,chunk2},2);
  chunk1=32768;
  chunk2=1;
  BinaryItemSet set2=new BinaryItemSet(new char[]{chunk1,chunk2},2);
  chunk1=32769;
  chunk2=0;
  BinaryItemSet set3=new BinaryItemSet(new char[]{chunk1,chunk2},2);
  expected.add(set3);
  expected.add(set2);
  expected.add(set1);
  Collection<BinaryItemSet> result=BinaryItemSet.divideSet(inputSet);
  for (  BinaryItemSet binaryItemSet : result) {
    if (!expected.contains(binaryItemSet))     Assert.fail("String_Node_Str");
  }
}

Fixed version (ground truth):
@Test public void set_partition(){
  char chunk1=32769;
  char chunk2=1;
  BinaryItemSet inputSet=new BinaryItemSet(new char[]{chunk1,chunk2},3);
  List<BinaryItemSet> expected=new LinkedList<BinaryItemSet>();
  chunk1=1;
  chunk2=1;
  BinaryItemSet set1=new BinaryItemSet(new char[]{chunk1,chunk2},2);
  chunk1=32768;
  chunk2=1;
  BinaryItemSet set2=new BinaryItemSet(new char[]{chunk1,chunk2},2);
  chunk1=32769;
  chunk2=0;
  BinaryItemSet set3=new BinaryItemSet(new char[]{chunk1,chunk2},2);
  expected.add(set3);
  expected.add(set2);
  expected.add(set1);
  Collection<BinaryItemSet> result=BinaryItemSet.divideSet(inputSet);
  for (  BinaryItemSet binaryItemSet : result) {
    if (!expected.contains(binaryItemSet))     Assert.fail("String_Node_Str");
  }
  int expectedNumberOfAttrubutes=2;
  for (  BinaryItemSet binaryItemSet : result) {
    Assert.assertEquals(expectedNumberOfAttrubutes,binaryItemSet.getNumberOfAttributes());
  }
}
Program: 20424
Project: 20424
Buggy source:
@Override protected void startSetGeneration(DataRepresentationBase data,double minSupport,double minCredibility){
  this.minSupport=minSupport;
  this.minCredibility=minCredibility;
  this.supportThreshold=(int)Math.ceil(data.getTransactionsList().size() * minSupport);
  SortedMap<BinaryItemSet,Integer> frequentSuppMap=this.binaryEngine.getSingleCandidateSets(data,supportThreshold);
  int generation=0;
  while (true) {
    Set<BinaryItemSet> candidates=this.binaryEngine.getCandidateSets(frequentSuppMap,generation++);
    Set<BinaryItemSet> approvedCandidates=this.binaryEngine.verifyCandidatesInData(data,candidates);
    if (approvedCandidates.size() == 0)     break;
  }
  frequentSet=frequentSuppMap;
}

Fixed version (ground truth):
@Override protected void startSetGeneration(DataRepresentationBase data,double minSupport,double minCredibility){
  this.minSupport=minSupport;
  this.minCredibility=minCredibility;
  this.supportThreshold=(int)Math.ceil(data.getTransactionsList().size() * minSupport);
  SortedMap<BinaryItemSet,Integer> frequentSuppMap=this.binaryEngine.getSingleCandidateSets(data,supportThreshold);
  Set<BinaryItemSet> approvedCandidates=frequentSuppMap.keySet();
  int generation=0;
  while (true) {
    Set<BinaryItemSet> candidates=this.binaryEngine.getCandidateSets(approvedCandidates,generation++);
    approvedCandidates=this.binaryEngine.verifyCandidatesInData(data,candidates);
    if (approvedCandidates.size() == 0)     break;
  }
  frequentSet=frequentSuppMap;
}
Program: 20425
Project: 20425
Buggy source:
/** 
 * Gets from   {@link BinaryItemSet} with n attributes. N{@link BinaryItemSet} objects each with <i>n -1</i> attributes.
 * @param inputSet : set to be divided.
 * @return Collection of sets with <i>n-1</i> attributes.
 */
public static Collection<BinaryItemSet> divideSet(BinaryItemSet inputSet){
  Set<BinaryItemSet> output=new LinkedHashSet<BinaryItemSet>();
  char[] vector=inputSet.getAttributeVector();
  int generation=inputSet.getNumberOfAttributes();
  int newGeneration=generation - 1;
  for (int i=0; i < vector.length; i++) {
    char mask=32768;
    for (int j=0; j < 16; j++) {
      char invertedMask=(char)~mask;
      char outChunk=(char)(invertedMask & vector[i]);
      if (outChunk != vector[i]) {
        char[] newElements=vector.clone();
        newElements[i]=outChunk;
        BinaryItemSet set=new BinaryItemSet(newElements,newGeneration);
        output.add(set);
      }
      mask=(char)(mask >>> 1);
    }
  }
  return output;
}

Fixed version (ground truth):
/** 
 * Gets from   {@link BinaryItemSet} with n attributes. N{@link BinaryItemSet} objects each with <i>n -1</i> attributes.
 * @param inputSet : set to be divided.
 * @return Collection of sets with <i>n-1</i> attributes.
 */
public static Collection<BinaryItemSet> divideSet(BinaryItemSet inputSet){
  return divideSet(inputSet.getAttributeVector(),inputSet.getNumberOfAttributes());
}
Program: 20426
Project: 20426
Buggy source:
public Set<BinaryItemSet> getCandidateSets(SortedMap<BinaryItemSet,Integer> frequentSupportMap,int generation){
  Set<BinaryItemSet> output=new TreeSet<BinaryItemSet>();
  List<BinaryItemSet> minuseOneSets=new LinkedList<BinaryItemSet>();
  for (  Map.Entry<BinaryItemSet,Integer> binaryItemSet : frequentSupportMap.entrySet()) {
    BinaryItemSet itemSet=binaryItemSet.getKey();
    if (itemSet.getNumberOfAttributes() == generation) {
      minuseOneSets.add(itemSet);
    }
  }
  for (  BinaryItemSet itemSet : minuseOneSets) {
    for (    BinaryItemSet singleItemSet : this.levelOneSet) {
      if (itemSet.compareTo(singleItemSet) < 0) {
        char[] vector=itemSet.getAttributeVector();
        char[] singleVector=singleItemSet.getAttributeVector();
        int vectorLength=singleVector.length;
        char[] outputVector=new char[vectorLength];
        for (int i=0; i < vectorLength; i++) {
          outputVector[i]=(char)(vector[i] | singleVector[i]);
        }
        boolean hasSupport=true;
        Collection<BinaryItemSet> items=BinaryItemSet.divideSet(itemSet);
        for (        BinaryItemSet binaryItemSet : items) {
          if (!frequentSupportMap.containsKey(binaryItemSet)) {
            hasSupport=false;
          }
        }
        if (hasSupport) {
          BinaryItemSet candidate=new BinaryItemSet(vector,generation);
          output.add(candidate);
        }
      }
    }
  }
  return output;
}

Fixed version (ground truth):
public Set<BinaryItemSet> getCandidateSets(Set<BinaryItemSet> frequentSupportMap,int generation){
  Set<BinaryItemSet> output=new TreeSet<BinaryItemSet>();
  for (  BinaryItemSet itemSet : frequentSupportMap) {
    for (    BinaryItemSet singleItemSet : this.levelOneSet) {
      if (itemSet.compareTo(singleItemSet) < 0) {
        char[] vector=itemSet.getAttributeVector();
        char[] singleVector=singleItemSet.getAttributeVector();
        int vectorLength=singleVector.length;
        char[] outputVector=new char[vectorLength];
        for (int i=0; i < vectorLength; i++) {
          outputVector[i]=(char)(vector[i] | singleVector[i]);
        }
        boolean hasSupport=true;
        Collection<BinaryItemSet> items=BinaryItemSet.divideSet(outputVector,generation);
        for (        BinaryItemSet binaryItemSet : items) {
          if (!frequentSupportMap.contains(binaryItemSet)) {
            hasSupport=false;
          }
        }
        if (hasSupport) {
          BinaryItemSet candidate=new BinaryItemSet(outputVector,generation);
          output.add(candidate);
        }
      }
    }
  }
  return output;
}
Program: 20427
Project: 20427
Buggy source:
public Set<BinaryItemSet> getCandidateSets(SortedMap<BinaryItemSet,Integer> frequentSupportMap,int i);

Fixed version (ground truth):
public Set<BinaryItemSet> getCandidateSets(Set<BinaryItemSet> approvedCandidates,int i);
Program: 20428
Project: 20428
Buggy source:
public Set<BinaryItemSet> getCandidateSets(SortedMap<BinaryItemSet,Integer> frequentSupportMap,int i){
  return null;
}

Fixed version (ground truth):
public Set<BinaryItemSet> getCandidateSets(Set<BinaryItemSet> frequentSupportMap,int i){
  return null;
}
Program: 20429
Project: 20429
Buggy source:
@Test public void no_set_can_be_generated_from_current_stage_maximum_generation(){
  frequentSupportMap=new TreeMap<BinaryItemSet,Integer>();
  char vector=57344;
  frequentSupportMap.put(new BinaryItemSet(new char[]{vector}),1);
  Set<BinaryItemSet> result=engine.getCandidateSets(frequentSupportMap,1);
  Assert.assertTrue(expecetCandidates.equals(result));
}

Fixed version (ground truth):
@Test public void no_set_can_be_generated_from_current_stage_maximum_generation(){
  frequentSupportMap=new TreeMap<BinaryItemSet,Integer>();
  String dataString="String_Node_Str";
  Integer support=0;
  DataRepresentationBase data=getDataFromString(dataString);
  engine.getSingleCandidateSets(data,support);
  char vector=57344;
  frequentSupportMap.put(new BinaryItemSet(new char[]{vector}),1);
  Set<BinaryItemSet> result=engine.getCandidateSets(frequentSupportMap.keySet(),1);
  Assert.assertTrue(expecetCandidates.equals(result));
}
Program: 20430
Project: 20430
Buggy source:
@Test public void generatin_level_two_sets_from_one_level_sets(){
  Integer support=0;
  String dataString="String_Node_Str";
  char vector=49152;
  BinaryItemSet set1=new BinaryItemSet(new char[]{vector});
  vector=40960;
  BinaryItemSet set2=new BinaryItemSet(new char[]{vector});
  vector=24576;
  BinaryItemSet set3=new BinaryItemSet(new char[]{vector});
  expecetCandidates.add(set1);
  expecetCandidates.add(set2);
  expecetCandidates.add(set3);
  DataRepresentationBase data=getDataFromString(dataString);
  frequentSupportMap=engine.getSingleCandidateSets(data,support);
  Set<BinaryItemSet> result=engine.getCandidateSets(frequentSupportMap,1);
  Assert.assertTrue(expecetCandidates.equals(result));
}

Fixed version (ground truth):
@Test public void generatin_level_two_sets_from_one_level_sets(){
  Integer support=0;
  String dataString="String_Node_Str";
  char vector=49152;
  BinaryItemSet set1=new BinaryItemSet(new char[]{vector});
  vector=40960;
  BinaryItemSet set2=new BinaryItemSet(new char[]{vector});
  vector=24576;
  BinaryItemSet set3=new BinaryItemSet(new char[]{vector});
  expecetCandidates.add(set1);
  expecetCandidates.add(set2);
  expecetCandidates.add(set3);
  DataRepresentationBase data=getDataFromString(dataString);
  frequentSupportMap=engine.getSingleCandidateSets(data,support);
  Set<BinaryItemSet> result=engine.getCandidateSets(frequentSupportMap.keySet(),1);
  Assert.assertTrue(expecetCandidates.equals(result));
}
Program: 20431
Project: 20431
Buggy source:
@Test public void generating_level_three_sets_from_level_two(){
  frequentSupportMap=new TreeMap<BinaryItemSet,Integer>();
  char setVector=0;
  setVector=49152;
  frequentSupportMap.put(new BinaryItemSet(new char[]{setVector}),1);
  setVector=40960;
  frequentSupportMap.put(new BinaryItemSet(new char[]{setVector}),1);
  setVector=24576;
  frequentSupportMap.put(new BinaryItemSet(new char[]{setVector}),1);
  char vector=57344;
  BinaryItemSet set1=new BinaryItemSet(new char[]{vector});
  expecetCandidates.add(set1);
  Set<BinaryItemSet> result=engine.getCandidateSets(frequentSupportMap,1);
  Assert.assertTrue(expecetCandidates.equals(result));
}

Fixed version (ground truth):
@Test public void generating_level_three_sets_from_level_two(){
  frequentSupportMap=new TreeMap<BinaryItemSet,Integer>();
  char setVector=0;
  String dataString="String_Node_Str";
  Integer support=0;
  DataRepresentationBase data=getDataFromString(dataString);
  engine.getSingleCandidateSets(data,support);
  setVector=49152;
  frequentSupportMap.put(new BinaryItemSet(new char[]{setVector}),1);
  setVector=40960;
  frequentSupportMap.put(new BinaryItemSet(new char[]{setVector}),1);
  setVector=24576;
  frequentSupportMap.put(new BinaryItemSet(new char[]{setVector}),1);
  char vector=57344;
  BinaryItemSet set1=new BinaryItemSet(new char[]{vector});
  expecetCandidates.add(set1);
  Set<BinaryItemSet> result=engine.getCandidateSets(frequentSupportMap.keySet(),1);
  Assert.assertTrue(expecetCandidates.equals(result));
}
Program: 20432
Project: 20432
Buggy source:
public DataRepresentationBase loadData(){
  Reader fileReader=null;
  try {
    fileReader=new FileReader(inputFile);
  }
 catch (  FileNotFoundException e) {
  }
  return fomratter.getFormattedData(fileReader);
}

Fixed version (ground truth):
public DataRepresentationBase loadData(){
  Reader fileReader=null;
  DataRepresentationBase data=null;
  try {
    fileReader=new FileReader(inputFile);
    data=fomratter.getFormattedData(fileReader);
    fileReader.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return data;
}
Program: 20433
Project: 20433
Buggy source:
@Before public void set_up(){
  mockFormatter=Mockito.mock(IDataFormatter.class);
  loader=new SimpleDataLoader(mockFormatter);
  fileName="String_Node_Str";
  file=new File(fileName);
  if (file.exists())   file.delete();
  try {
    file.createNewFile();
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
@Before public void set_up(){
  mockFormatter=Mockito.mock(IDataFormatter.class);
  loader=new SimpleDataLoader(mockFormatter);
  fileName="String_Node_Str";
  file=new File(fileName);
  try {
    file.createNewFile();
  }
 catch (  IOException e) {
  }
}
Program: 20434
Project: 20434
Buggy source:
@Override public boolean canFindUsagesFor(@NotNull PsiElement psiElement){
  return psiElement instanceof PNameNsDeclaration;
}

Fixed version (ground truth):
@Override public boolean canFindUsagesFor(@NotNull PsiElement psiElement){
  return psiElement instanceof PNameNsDeclaration || psiElement instanceof VariablePsiElement;
}
Program: 20435
Project: 20435
Buggy source:
@Override public WordsScanner getWordsScanner(){
  return new DefaultWordsScanner(new SparqlLexer(),TokenSet.create(SparqlTokenTypes.LIT_PNAME_LN,SparqlTokenTypes.LIT_PNAME_NS,SparqlTokenTypes.VAR),SparqlTokenTypeSets.COMMENTS,TokenSet.create());
}

Fixed version (ground truth):
@Override public WordsScanner getWordsScanner(){
  return new DefaultWordsScanner(new SparqlLexer(),TokenSet.create(SparqlTokenTypes.LIT_PNAME_LN,SparqlTokenTypes.LIT_PNAME_NS,SparqlTokenTypes.VAR),SparqlTokenTypeSets.COMMENTS,TokenSet.andSet(SparqlTokenTypeSets.NUMBER_LITERALS,SparqlTokenTypeSets.STRING_LITERALS));
}
Program: 20436
Project: 20436
Buggy source:
private static Predicate issuer(QIssuer path,String entityID,String entityUID,String entityUIDType,boolean matchUnknown){
  Predicate predicate=ExpressionUtils.allOf(wildCard(QIssuer.issuer.entityID,entityID,false,false),wildCard(QIssuer.issuer.entityUID,entityUID,false,false),wildCard(QIssuer.issuer.entityUIDType,entityUIDType,false,false));
  if (predicate == null)   return null;
  return matchUnknown(new HibernateSubQuery().from(QIssuer.issuer).where(QIssuer.issuer.eq(path),predicate).exists(),path,matchUnknown);
}

Fixed version (ground truth):
private static Predicate issuer(QIssuer path,String entityID,String entityUID,String entityUIDType,boolean matchUnknown){
  Predicate predicate=ExpressionUtils.anyOf(wildCard(QIssuer.issuer.entityID,entityID,false,false),ExpressionUtils.allOf(wildCard(QIssuer.issuer.entityUID,entityUID,false,false),wildCard(QIssuer.issuer.entityUIDType,entityUIDType,false,false)));
  if (predicate == null)   return null;
  return matchUnknown(new HibernateSubQuery().from(QIssuer.issuer).where(QIssuer.issuer.eq(path),predicate).exists(),path,matchUnknown);
}
Program: 20437
Project: 20437
Buggy source:
static Predicate wildCard(StringPath path,String value,boolean matchUnknown,boolean ignoreCase){
  if (value.equals("String_Node_Str"))   return null;
  Predicate predicate;
  StringExpression expr=ignoreCase && isUpperCase(value) ? path.toUpperCase() : path;
  if (containsWildcard(value)) {
    String pattern=toLikePattern(value);
    if (pattern.equals("String_Node_Str"))     return null;
    predicate=expr.like(pattern);
  }
 else   predicate=expr.eq(value);
  return matchUnknown(predicate,path,matchUnknown);
}

Fixed version (ground truth):
static Predicate wildCard(StringPath path,String value,boolean matchUnknown,boolean ignoreCase){
  if (value == null || value.equals("String_Node_Str"))   return null;
  Predicate predicate;
  StringExpression expr=ignoreCase && isUpperCase(value) ? path.toUpperCase() : path;
  if (containsWildcard(value)) {
    String pattern=toLikePattern(value);
    if (pattern.equals("String_Node_Str"))     return null;
    predicate=expr.like(pattern);
  }
 else   predicate=expr.eq(value);
  return matchUnknown(predicate,path,matchUnknown);
}
Program: 20438
Project: 20438
Buggy source:
public static IDWithIssuer pidWithIssuer(Attributes keys,Issuer defaultIssuerWithPatientID){
  String id=keys.getString(Tag.PatientID);
  if (id == null)   return null;
  String entityID=keys.getString(Tag.IssuerOfPatientID,"String_Node_Str");
  Attributes issuerItem=keys.getNestedDataset(Tag.IssuerOfPatientIDQualifiersSequence);
  String entityUID=issuerItem != null ? issuerItem.getString(Tag.UniversalEntityID,"String_Node_Str") : "String_Node_Str";
  String entityUIDType=issuerItem != null ? issuerItem.getString(Tag.UniversalEntityIDType,"String_Node_Str") : "String_Node_Str";
  Issuer issuer=entityID.equals("String_Node_Str") && entityUID.equals("String_Node_Str") && entityUIDType.equals("String_Node_Str") ? defaultIssuerWithPatientID : new Issuer(entityID,entityUID,entityUIDType);
  return new IDWithIssuer(id,issuer);
}

Fixed version (ground truth):
public static IDWithIssuer pidWithIssuer(Attributes keys,Issuer defaultIssuerWithPatientID){
  String id=keys.getString(Tag.PatientID);
  if (id == null)   return null;
  String entityID=keys.getString(Tag.IssuerOfPatientID);
  String entityUID=null;
  String entityUIDType=null;
  Attributes issuerItem=keys.getNestedDataset(Tag.IssuerOfPatientIDQualifiersSequence);
  if (issuerItem != null) {
    entityUID=issuerItem.getString(Tag.UniversalEntityID);
    entityUIDType=issuerItem.getString(Tag.UniversalEntityIDType);
  }
  Issuer issuer=entityID == null && entityUID == null && entityUIDType == null ? defaultIssuerWithPatientID : new Issuer(entityID,entityUID,entityUIDType);
  return new IDWithIssuer(id,issuer);
}
Program: 20439
Project: 20439
Buggy source:
public static Issuer getIssuer(EntityManager em,Attributes issuerItem){
  return issuerItem != null ? getIssuer(em,issuerItem.getString(Tag.CodeValue,null),issuerItem.getString(Tag.CodingSchemeDesignator,null),issuerItem.getString(Tag.CodingSchemeDesignator,null)) : null;
}

Fixed version (ground truth):
public static Issuer getIssuer(EntityManager em,Attributes issuerItem){
  return issuerItem != null ? getIssuer(em,issuerItem.getString(Tag.LocalNamespaceEntityID,null),issuerItem.getString(Tag.UniversalEntityID,null),issuerItem.getString(Tag.UniversalEntityIDType,null)) : null;
}
Program: 20440
Project: 20440
Buggy source:
@Test public void removeTestData(){
  removePatient.removePatient("String_Node_Str","String_Node_Str");
  removePatient.removePatient("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Test public void removeTestData(){
  removePatient.removePatient("String_Node_Str","String_Node_Str");
  removePatient.removePatient("String_Node_Str","String_Node_Str");
  removePatient.removePatient("String_Node_Str","String_Node_Str");
}
Program: 20441
Project: 20441
Buggy source:
@Deployment public static JavaArchive createDeployment(){
  return ShrinkWrap.create(JavaArchive.class,"String_Node_Str").addClasses(InstanceStore.class,InstanceStoreBean.class,CodeFactory.class,IssuerFactory.class,PatientFactory.class).addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str");
}

Fixed version (ground truth):
@Deployment public static JavaArchive createDeployment(){
  return ShrinkWrap.create(JavaArchive.class,"String_Node_Str").addClasses(InstanceStore.class,InstanceStoreBean.class,CodeFactory.class,IssuerFactory.class,PatientFactory.class).addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str").addAsResource("String_Node_Str");
}
Program: 20443
Project: 20443
Buggy source:
private void writePackets(Thread thisThread){
  try {
    while (!done && (writerThread == thisThread)) {
      Packet packet=nextPacket();
      if (packet != null) {
        Vector<Packet> packets=new Vector<Packet>();
        packets.add(packet);
        connection.writePacket(packets);
      }
    }
    try {
      Vector<Packet> packets=new Vector<Packet>();
      packets.addAll(queue);
      connection.writePacket(packets);
    }
 catch (    XMPPException e) {
    }
    queue.clear();
  }
 catch (  XMPPException ioe) {
    new Exception(ioe).printStackTrace();
    done=true;
  }
}

Fixed version (ground truth):
private void writePackets(Thread thisThread){
  try {
    while (!done && (writerThread == thisThread)) {
      Packet packet=nextPacket();
      if (packet != null) {
        Vector<Packet> packets=new Vector<Packet>();
        packets.add(packet);
        connection.writePacket(packets);
      }
    }
    try {
      Vector<Packet> packets=new Vector<Packet>();
      packets.addAll(queue);
      if (packets.size() > 0)       connection.writePacket(packets);
    }
 catch (    XMPPException e) {
    }
    queue.clear();
  }
 catch (  XMPPException ioe) {
    new Exception(ioe).printStackTrace();
    done=true;
  }
}
Program: 20444
Project: 20444
Buggy source:
/** 
 * Creates a new error with the specified code, type, condition and message. This constructor is used when the condition is not recognized automatically by XMPPError i.e. there is not a defined instance of ErrorCondition or it does not applies the default  specification.
 * @param code the error code.
 * @param type the error type.
 * @param condition the error condition.
 * @param message a message describing the error.
 * @param extension list of packet extensions
 */
public XMPPError(int code,Type type,String condition,String message,List<PacketExtension> extension){
  this.code=code;
  this.type=type;
  this.condition=condition;
  this.message=message;
  this.applicationExtensions=extension;
  if (this.code == -1 || this.type == null) {
    ErrorSpecification spec=ErrorSpecification.specFor(condition);
    if (spec != null) {
      if (this.code == -1)       this.code=spec.code;
      if (this.type == null)       this.type=spec.type;
    }
  }
}

Fixed version (ground truth):
/** 
 * Creates a new error with the specified code, type, condition and message. This constructor is used when the condition is not recognized automatically by XMPPError i.e. there is not a defined instance of ErrorCondition or it does not applies the default  specification.
 * @param code the error code.
 * @param type the error type.
 * @param condition the error condition.
 * @param message a message describing the error.
 * @param extension list of packet extensions
 */
public XMPPError(int code,Type type,String condition,String message,List<PacketExtension> extension){
  this.code=code;
  this.type=type;
  this.condition=condition;
  this.message=message;
  this.applicationExtensions=extension;
  if (this.code == -1 || this.type == null) {
    ErrorSpecification spec=ErrorSpecification.specFor(condition);
    if (spec != null) {
      if (this.code == -1)       this.code=spec.code;
      if (this.type == null)       this.type=spec.type;
    }
 else {
      this.code=0;
    }
  }
}
Program: 20445
Project: 20445
Buggy source:
/** 
 * Returns the JID representation of an XMPP entity contained as a SubjectAltName extension in the certificate. If none was found then return <tt>null</tt>.
 * @param certificate the certificate presented by the remote entity.
 * @return the JID representation of an XMPP entity contained as a SubjectAltName extensionin the certificate. If none was found then return <tt>null</tt>.
 */
private static List<String> getSubjectAlternativeNames(X509Certificate certificate){
  List<String> identities=new ArrayList<String>();
  try {
    Collection<List<?>> altNames=certificate.getSubjectAlternativeNames();
    if (altNames == null) {
      return Collections.emptyList();
    }
  }
 catch (  CertificateParsingException e) {
    e.printStackTrace();
  }
  return identities;
}

Fixed version (ground truth):
/** 
 * Returns the JID representation of an XMPP entity contained as a SubjectAltName extension in the certificate. If none was found then return <tt>null</tt>.
 * @param certificate the certificate presented by the remote entity.
 * @return the JID representation of an XMPP entity contained as a SubjectAltName extensionin the certificate. If none was found then return <tt>null</tt>.
 */
private static List<String> getSubjectAlternativeNames(X509Certificate certificate){
  Collection<List<?>> altNames;
  try {
    altNames=certificate.getSubjectAlternativeNames();
  }
 catch (  CertificateParsingException e) {
    e.printStackTrace();
    return Collections.emptyList();
  }
  if (altNames == null)   return Collections.emptyList();
  List<String> identities=new ArrayList<String>();
  for (  List item : altNames) {
    Integer type=(Integer)item.get(0);
    if (type == 2) {
      String s=(String)item.get(1);
      identities.add(s);
    }
  }
  return identities;
}
Program: 20446
Project: 20446
Buggy source:
private static InputStream getTruststoreStream(String path) throws IOException {
  if (path != null)   return new FileInputStream(path);
  String javaHome=System.getProperty("String_Node_Str");
  String[] defaultTruststorePaths={System.getProperty("String_Node_Str"),javaHome + "String_Node_Str",javaHome + "String_Node_Str"};
  for (  String candidate : Arrays.asList(defaultTruststorePaths)) {
    try {
      return new FileInputStream(candidate);
    }
 catch (    IOException e) {
    }
  }
  throw new IOException("String_Node_Str");
}

Fixed version (ground truth):
private static InputStream getTruststoreStream(String path) throws IOException {
  if (path != null)   return new FileInputStream(path);
  String javaHome=System.getProperty("String_Node_Str");
  String[] defaultTruststorePaths={System.getProperty("String_Node_Str"),javaHome + "String_Node_Str",javaHome + "String_Node_Str"};
  for (  String candidate : Arrays.asList(defaultTruststorePaths)) {
    if (candidate == null)     continue;
    try {
      return new FileInputStream(candidate);
    }
 catch (    IOException e) {
    }
  }
  throw new IOException("String_Node_Str");
}
Program: 20447
Project: 20447
Buggy source:
/** 
 * Returns the identity of the remote server as defined in the specified certificate. The identity is defined in the subjectDN of the certificate and it can also be defined in the subjectAltName extension of type "xmpp". When the extension is being used then the identity defined in the extension in going to be returned. Otherwise, the value stored in the subjectDN is returned.
 * @param x509Certificate the certificate the holds the identity of the remote server.
 * @return the identity of the remote server as defined in the specified certificate.
 */
public static List<String> getPeerIdentity(X509Certificate x509Certificate){
  List<String> names=getSubjectAlternativeNames(x509Certificate);
  if (names.isEmpty()) {
    String name=x509Certificate.getSubjectDN().getName();
    Matcher matcher=cnPattern.matcher(name);
    if (matcher.find()) {
      name=matcher.group(2);
    }
    names=new ArrayList<String>();
    names.add(name);
  }
  return names;
}

Fixed version (ground truth):
/** 
 * @param x509Certificate the certificate the holds the identity of the remote server.
 * @return the identity of the remote server as defined in the specified certificate.
 */
public static List<String> getPeerIdentity(X509Certificate x509Certificate){
  List<String> names=new Vector<String>();
  String name=x509Certificate.getSubjectDN().getName();
  Matcher matcher=cnPattern.matcher(name);
  if (matcher.find()) {
    name=matcher.group(2);
  }
  names.add(name);
  names.addAll(getSubjectAlternativeNames(x509Certificate));
  return names;
}
Program: 20448
Project: 20448
Buggy source:
private String authenticateUsingMechanism(String username,CallbackHandler cbh,String password,String resource,String mechanism) throws XMPPException, SASLMechanism.MechanismNotSupported {
  if (saslNegotiated)   throw new XMPPException("String_Node_Str");
  init();
  currentMechanism=createMechanism(implementedMechanisms.get(mechanism));
  try {
    if (cbh != null)     currentMechanism.authenticate(username,connection.getServiceName(),cbh);
 else     currentMechanism.authenticate(username,connection.getServiceName(),password);
  }
 catch (  IOException e) {
    e.printStackTrace();
    throw new XMPPException(e);
  }
synchronized (this) {
    if (!saslNegotiated && !saslFailed) {
      try {
        wait(30000);
      }
 catch (      InterruptedException e) {
      }
    }
  }
  if (!saslNegotiated && !saslFailed)   throw new XMPPException("String_Node_Str",XMPPError.Condition.request_timeout);
  if (saslFailed) {
    if (errorCondition != null) {
      throw new XMPPException("String_Node_Str" + mechanism + "String_Node_Str"+ errorCondition);
    }
 else {
      throw new XMPPException("String_Node_Str" + mechanism + "String_Node_Str");
    }
  }
  return bindResourceAndEstablishSession(resource);
}

Fixed version (ground truth):
private String authenticateUsingMechanism(String username,CallbackHandler cbh,String password,String resource,String mechanism) throws XMPPException, SASLMechanism.MechanismNotSupported {
  if (saslNegotiated)   throw new XMPPException("String_Node_Str");
  init();
  currentMechanism=createMechanism(implementedMechanisms.get(mechanism));
  try {
    if (cbh != null)     currentMechanism.authenticate(username,connection.getServiceName(),cbh);
 else     currentMechanism.authenticate(username,connection.getServiceName(),password);
  }
 catch (  IOException e) {
    e.printStackTrace();
    throw new XMPPException(e);
  }
synchronized (this) {
    if (!saslNegotiated && !saslFailed) {
      try {
        wait(30000);
      }
 catch (      InterruptedException e) {
      }
    }
  }
  if (!saslNegotiated && !saslFailed)   throw new XMPPException("String_Node_Str",XMPPError.Condition.request_timeout);
  if (saslFailed) {
    if (errorCondition != null) {
      throw new XMPPException("String_Node_Str" + mechanism + "String_Node_Str"+ errorCondition,XMPPError.fromErrorType(errorCondition));
    }
 else {
      throw new XMPPException("String_Node_Str" + mechanism + "String_Node_Str");
    }
  }
  return bindResourceAndEstablishSession(resource);
}
Program: 20449
Project: 20449
Buggy source:
/** 
 * Just create an account.
 */
protected void setUp() throws Exception {
  super.setUp();
  XMPPConnection setupConnection=new XMPPConnection(getServiceName());
  setupConnection.connect();
  if (!setupConnection.getAccountManager().supportsAccountCreation())   fail("String_Node_Str");
  try {
    setupConnection.getAccountManager().createAccount("String_Node_Str","String_Node_Str");
  }
 catch (  XMPPException e) {
    if (e.getXMPPError().getCode() != 409) {
      throw e;
    }
  }
}

Fixed version (ground truth):
/** 
 * Just create an account.
 */
protected void setUp() throws Exception {
  super.setUp();
  XMPPConnection setupConnection=new XMPPConnection(getServiceName());
  setupConnection.connect();
  if (!setupConnection.getAccountManager().supportsAccountCreation())   fail("String_Node_Str");
  try {
    setupConnection.getAccountManager().createAccount("String_Node_Str","String_Node_Str");
  }
 catch (  XMPPException e) {
    if (!e.getXMPPError().getCondition().equals("String_Node_Str")) {
      throw e;
    }
  }
}
Program: 20450
Project: 20450
Buggy source:
/** 
 * Check that the server is returning the correct error when trying to login using an invalid (i.e. non-existent) user.
 */
public void testInvalidLogin(){
  try {
    XMPPConnection connection=createConnection();
    connection.connect();
    try {
      connection.login("String_Node_Str","String_Node_Str");
      connection.disconnect();
      fail("String_Node_Str");
    }
 catch (    XMPPException e) {
      if (e.getXMPPError() != null) {
        assertEquals("String_Node_Str",401,e.getXMPPError().getCode());
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Check that the server is returning the correct error when trying to login using an invalid (i.e. non-existent) user.
 */
public void testInvalidLogin(){
  try {
    XMPPConnection connection=createConnection();
    connection.connect();
    try {
      connection.login("String_Node_Str","String_Node_Str");
      connection.disconnect();
      fail("String_Node_Str");
    }
 catch (    XMPPException e) {
      assertNotNull("String_Node_Str",e.getXMPPError());
      assertEquals("String_Node_Str",401,e.getXMPPError().getCode());
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
}
Program: 20452
Project: 20452
Buggy source:
public void disconnect(Presence unavailablePresence){
  packetReader.assertNotInThread();
  if (!connected)   return;
  suppressConnectionErrors=true;
  shutdown(unavailablePresence);
  if (roster != null) {
    roster.cleanup();
    roster=null;
  }
  wasAuthenticated=false;
  suppressConnectionErrors=false;
  notifyConnectionClosed();
}

Fixed version (ground truth):
public void disconnect(Presence unavailablePresence){
  packetReader.assertNotInThread();
  boolean wasConnected;
synchronized (this) {
    wasConnected=connected;
    connected=false;
  }
  suppressConnectionErrors=true;
  shutdown(unavailablePresence);
  if (roster != null) {
    roster.cleanup();
    roster=null;
  }
  wasAuthenticated=false;
  suppressConnectionErrors=false;
  if (wasConnected)   notifyConnectionClosed();
}
Program: 20453
Project: 20453
Buggy source:
/** 
 * Establishes a connection to the XMPP server and performs an automatic login only if the previous connection state was logged (authenticated). It basically creates and maintains a socket connection to the server.<p> <p/> Listeners will be preserved from a previous connection if the reconnection occurs after an abrupt termination.
 * @throws XMPPException if an error occurs while trying to establish the connection.Two possible errors can occur which will be wrapped by an XMPPException -- UnknownHostException (XMPP error code 504), and IOException (XMPP error code 502). The error codes and wrapped exceptions can be used to present more appropiate error messages to end-users.
 */
public void connect() throws XMPPException {
  packetReader.assertNotInThread();
  connectUsingConfiguration();
  if (connected && wasAuthenticated) {
    try {
      if (isAnonymous()) {
        loginAnonymously();
      }
 else {
        login(config.getUsername(),config.getPassword(),config.getResource());
      }
      notifyReconnection();
    }
 catch (    XMPPException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * Establishes a connection to the XMPP server and performs an automatic login only if the previous connection state was logged (authenticated). It basically creates and maintains a socket connection to the server.<p> <p/> Listeners will be preserved from a previous connection if the reconnection occurs after an abrupt termination.
 * @throws XMPPException if an error occurs while trying to establish the connection.Two possible errors can occur which will be wrapped by an XMPPException -- UnknownHostException (XMPP error code 504), and IOException (XMPP error code 502). The error codes and wrapped exceptions can be used to present more appropiate error messages to end-users.
 */
public void connect() throws XMPPException {
  packetReader.assertNotInThread();
  shutdown(null);
  connectUsingConfiguration();
  if (connected && wasAuthenticated) {
    try {
      if (isAnonymous()) {
        loginAnonymously();
      }
 else {
        login(config.getUsername(),config.getPassword(),config.getResource());
      }
      notifyReconnection();
    }
 catch (    XMPPException e) {
      e.printStackTrace();
    }
  }
}
Program: 20454
Project: 20454
Buggy source:
/** 
 * Closes the connection by setting presence to unavailable then closing the stream to the XMPP server. The shutdown logic will be used during a planned disconnection or when dealing with an unexpected disconnection. Unlike   {@link #disconnect()} the connection'spacket reader, packet writer, and  {@link Roster} will not be removed; thusconnection's state is kept.
 * @param unavailablePresence the presence packet to send during shutdown.
 */
protected void shutdown(Presence unavailablePresence){
  packetReader.assertNotInThread();
  if (unavailablePresence != null)   packetWriter.sendPacket(unavailablePresence);
  data_stream.disconnect();
  packetReader.shutdown();
  packetWriter.shutdown();
  data_stream=null;
  saslAuthentication.init();
  this.setWasAuthenticated(authenticated);
  authenticated=false;
  connected=false;
}

Fixed version (ground truth):
/** 
 * Closes the connection by setting presence to unavailable then closing the stream to the XMPP server. The shutdown logic will be used during a planned disconnection or when dealing with an unexpected disconnection. Unlike   {@link #disconnect()} the connection'spacket reader, packet writer, and  {@link Roster} will not be removed; thusconnection's state is kept.
 * @param unavailablePresence the presence packet to send during shutdown.
 */
protected void shutdown(Presence unavailablePresence){
  packetReader.assertNotInThread();
  if (unavailablePresence != null)   packetWriter.sendPacket(unavailablePresence);
  if (data_stream != null)   data_stream.disconnect();
  packetReader.shutdown();
  packetWriter.shutdown();
  data_stream=null;
  saslAuthentication.init();
  this.setWasAuthenticated(authenticated);
  authenticated=false;
  connected=false;
}
Program: 20455
Project: 20455
Buggy source:
/** 
 * Called by PacketReader when an error occurs after startup() returns successfully.
 * @param error the exception that caused the connection close event.
 */
protected void readerThreadException(Exception error){
synchronized (this) {
    if (suppressConnectionErrors)     return;
    suppressConnectionErrors=true;
  }
  new Exception(error).printStackTrace();
synchronized (this) {
    while (!readyForDisconnection) {
      try {
        this.wait();
      }
 catch (      InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }
  }
  this.data_stream.disconnect();
  notifyConnectionClosedOnError(error);
}

Fixed version (ground truth):
/** 
 * Called by PacketReader when an error occurs after startup() returns successfully.
 * @param error the exception that caused the connection close event.
 */
protected void readerThreadException(Exception error){
synchronized (this) {
    if (suppressConnectionErrors)     return;
    suppressConnectionErrors=true;
  }
  new Exception(error).printStackTrace();
  boolean wasConnected;
synchronized (this) {
    while (!readyForDisconnection) {
      try {
        this.wait();
      }
 catch (      InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }
    wasConnected=connected;
    connected=false;
  }
  this.data_stream.disconnect();
  if (wasConnected)   notifyConnectionClosedOnError(error);
}