nus-yam/ex-repair huggingface dataset:
Program: 101744
Project: 101744
Buggy source:
/** 
 * Read all the modules that we can get our hands on.
 */
public static void main(String[] args) throws IOException, JDOMException {
  Logger.outputInfoMinimum();
  JAXBUtil.getJAXBContext();
  Config config=new Config("String_Node_Str");
  Document xmlconfig=Project.resource().getDocument("String_Node_Str");
  config.add(xmlconfig);
  config.setProperties(Project.resource().getProperties("String_Node_Str"));
  config.localToApplication(true);
  List dicts=Books.getBooks(BookFilters.getDictionaries());
  for (Iterator dit=dicts.iterator(); dit.hasNext(); ) {
    DictionaryMetaData dmd=(DictionaryMetaData)dit.next();
    if (dmd.getInitials().compareTo("String_Node_Str") < 1) {
      continue;
    }
    Dictionary dict=dmd.getDictionary();
    SortedSet set=dict.getIndex(null);
    Iterator it=set.iterator();
    testReadMultiple(dmd,it);
  }
  List comments=Books.getBooks(BookFilters.getCommentaries());
  for (Iterator cit=comments.iterator(); cit.hasNext(); ) {
    BookMetaData bmd=(BookMetaData)cit.next();
    Iterator it=new KeyIterator(WHOLE.verseIterator());
    testReadMultiple(bmd,it);
  }
  List bibles=Books.getBooks(BookFilters.getBibles());
  for (Iterator bit=bibles.iterator(); bit.hasNext(); ) {
    BookMetaData bmd=(BookMetaData)bit.next();
    Iterator it=new KeyIterator(WHOLE.verseIterator());
    testReadMultiple(bmd,it);
  }
}

Fixed version (ground truth):
/** 
 * Read all the modules that we can get our hands on.
 */
public static void main(String[] args) throws IOException, JDOMException {
  Logger.outputInfoMinimum();
  JAXBUtil.getJAXBContext();
  Config config=new Config("String_Node_Str");
  Document xmlconfig=Project.resource().getDocument("String_Node_Str");
  config.add(xmlconfig);
  config.setProperties(Project.resource().getProperties("String_Node_Str"));
  config.localToApplication(true);
  List bibles=Books.getBooks(BookFilters.getBibles());
  for (Iterator bit=bibles.iterator(); bit.hasNext(); ) {
    BookMetaData bmd=(BookMetaData)bit.next();
    Iterator it=new KeyIterator(WHOLE.verseIterator());
    testReadMultiple(bmd,it);
  }
  List dicts=Books.getBooks(BookFilters.getDictionaries());
  for (Iterator dit=dicts.iterator(); dit.hasNext(); ) {
    DictionaryMetaData dmd=(DictionaryMetaData)dit.next();
    if (dmd.getInitials().compareTo("String_Node_Str") < 1) {
      continue;
    }
    Dictionary dict=dmd.getDictionary();
    SortedSet set=dict.getIndex(null);
    Iterator it=set.iterator();
    testReadMultiple(dmd,it);
  }
  List comments=Books.getBooks(BookFilters.getCommentaries());
  for (Iterator cit=comments.iterator(); cit.hasNext(); ) {
    BookMetaData bmd=(BookMetaData)cit.next();
    Iterator it=new KeyIterator(WHOLE.verseIterator());
    testReadMultiple(bmd,it);
  }
}
Program: 101745
Project: 101745
Buggy source:
/** 
 * XML parse failed, so we can try getting rid of all the tags and having another go. We define a tag to start at a &lt; and end at the end of the next word (where a word is what comes in between spaces) that does not contain an = sign, or at a >, whichever is earlier.
 */
public static String cleanAllTags(String broken){
  if (broken == null) {
    return null;
  }
  String working=broken;
  allTags:   while (true) {
    int lt=working.indexOf('<');
    if (lt == -1) {
      break allTags;
    }
    int i=lt;
    int startattr=-1;
    singletag:     while (true) {
      i++;
      if (i >= working.length()) {
        i--;
        break singletag;
      }
      char c=working.charAt(i);
      if (c == '>') {
        break singletag;
      }
      if (c == ' ') {
        if (startattr == -1) {
          startattr=i;
        }
 else {
          String value=working.substring(startattr,i);
          if (value.indexOf("String_Node_Str") == -1) {
            break singletag;
          }
        }
      }
    }
    DataPolice.report("String_Node_Str" + working.substring(lt,i + 1));
    working=working.substring(0,lt) + working.substring(i + 1);
  }
  return working;
}

Fixed version (ground truth):
/** 
 * XML parse failed, so we can try getting rid of all the tags and having another go. We define a tag to start at a &lt; and end at the end of the next word (where a word is what comes in between spaces) that does not contain an = sign, or at a >, whichever is earlier.
 */
public static String cleanAllTags(String broken){
  if (broken == null) {
    return null;
  }
  String working=broken;
  allTags:   while (true) {
    int lt=working.indexOf('<');
    if (lt == -1) {
      break allTags;
    }
    int i=lt;
    int startattr=-1;
    singletag:     while (true) {
      i++;
      if (i >= working.length()) {
        i--;
        break singletag;
      }
      char c=working.charAt(i);
      if (c == '>') {
        break singletag;
      }
      if (c == ' ') {
        if (startattr == -1) {
          startattr=i;
        }
 else {
          String value=working.substring(startattr,i);
          if (value.indexOf("String_Node_Str") == -1) {
            break singletag;
          }
        }
      }
    }
    working=working.substring(0,lt) + working.substring(i + 1);
  }
  return working;
}
Program: 101746
Project: 101746
Buggy source:
/** 
 * A parse has failed so we can try to kill the broken entities and then have another go.
 */
public static String cleanAllEntities(String broken){
  if (broken == null) {
    return null;
  }
  String working=broken;
  int cleanfrom=0;
  allEntities:   while (true) {
    int amp=working.indexOf('&',cleanfrom);
    if (amp == -1) {
      break allEntities;
    }
    int i=amp + 1;
    singleEntity:     while (true) {
      if (i >= working.length()) {
        String entity=working.substring(amp);
        String replace=guessEntity(entity);
        DataPolice.report("String_Node_Str" + entity + "String_Node_Str"+ replace+ "String_Node_Str");
        working=working.substring(0,amp) + replace;
        break singleEntity;
      }
      char c=working.charAt(i);
      if (c == ';') {
        String entity=working.substring(amp,i + 1);
        String replace=guessEntity(entity);
        DataPolice.report("String_Node_Str" + entity + "String_Node_Str"+ replace+ "String_Node_Str");
        working=working.substring(0,amp) + replace + working.substring(i + 1);
        break singleEntity;
      }
      if (!Character.isLetterOrDigit(c) && c != '-') {
        String entity=working.substring(amp,i);
        String replace=guessEntity(entity);
        DataPolice.report("String_Node_Str" + entity + "String_Node_Str"+ replace+ "String_Node_Str");
        working=working.substring(0,amp) + replace + working.substring(i);
        break singleEntity;
      }
      i++;
    }
    cleanfrom=amp + 1;
  }
  return working;
}

Fixed version (ground truth):
/** 
 * A parse has failed so we can try to kill the broken entities and then have another go.
 */
public static String cleanAllEntities(String broken){
  if (broken == null) {
    return null;
  }
  String working=broken;
  int cleanfrom=0;
  allEntities:   while (true) {
    int amp=working.indexOf('&',cleanfrom);
    if (amp == -1) {
      break allEntities;
    }
    int i=amp + 1;
    singleEntity:     while (true) {
      if (i >= working.length()) {
        String entity=working.substring(amp);
        String replace=guessEntity(entity);
        working=working.substring(0,amp) + replace;
        break singleEntity;
      }
      char c=working.charAt(i);
      if (c == ';') {
        String entity=working.substring(amp,i + 1);
        String replace=guessEntity(entity);
        working=working.substring(0,amp) + replace + working.substring(i + 1);
        break singleEntity;
      }
      if (!Character.isLetterOrDigit(c) && c != '-') {
        String entity=working.substring(amp,i);
        String replace=guessEntity(entity);
        working=working.substring(0,amp) + replace + working.substring(i);
        break singleEntity;
      }
      i++;
    }
    cleanfrom=amp + 1;
  }
  return working;
}
Program: 101747
Project: 101747
Buggy source:
/** 
 * The parser failed, and it might be because there are control characters that are not valid in XML in the string, so this method strips them out
 */
public static String cleanInvalidCharacters(String broken){
  if (broken == null) {
    return null;
  }
  StringBuffer buffer=new StringBuffer();
  for (int i=0; i < broken.length(); i++) {
    char c=broken.charAt(i);
    if (c < 32 && c != 9 && c != 10 && c != 13) {
      int num=c;
      DataPolice.report("String_Node_Str" + num);
    }
 else {
      buffer.append(c);
    }
  }
  return buffer.toString();
}

Fixed version (ground truth):
/** 
 * The parser failed, and it might be because there are control characters that are not valid in XML in the string, so this method strips them out
 */
public static String cleanInvalidCharacters(String broken){
  if (broken == null) {
    return null;
  }
  StringBuffer buffer=new StringBuffer();
  for (int i=0; i < broken.length(); i++) {
    char c=broken.charAt(i);
    if (c < 32 && c != 9 && c != 10 && c != 13) {
    }
 else {
      buffer.append(c);
    }
  }
  return buffer.toString();
}
Program: 101748
Project: 101748
Buggy source:
/** 
 * Flush the stream.  If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination.  Then, if that destination is another character or byte stream, flush it.  Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.
 * @exception IOException  If an I/O error occurs
 */
public void flush() throws IOException {
  if (updater != null) {
    try {
      SwingUtilities.invokeAndWait(updater);
    }
 catch (    InterruptedException ex) {
      throw new IOException("String_Node_Str" + ex);
    }
catch (    InvocationTargetException ex) {
      throw new IOException("String_Node_Str" + ex);
    }
  }
}

Fixed version (ground truth):
public void flush() throws IOException {
  if (updater != null) {
    try {
      SwingUtilities.invokeAndWait(updater);
    }
 catch (    InterruptedException ex) {
      throw new IOException("String_Node_Str" + ex);
    }
catch (    InvocationTargetException ex) {
      throw new IOException("String_Node_Str" + ex);
    }
  }
}
Program: 101749
Project: 101749
Buggy source:
/** 
 * Write a portion of a string.
 * @param str A String
 * @param off Offset from which to start writing characters
 * @param len Number of characters to write
 * @exception IOException If an I/O error occurs
 */
public void write(String str,int off,int len) throws IOException {
synchronized (lock) {
    queue=queue + str.substring(off,off + len);
    update();
  }
}

Fixed version (ground truth):
public void write(String str,int off,int len){
synchronized (lock) {
    queue=queue + str.substring(off,off + len);
    update();
  }
}
Program: 101750
Project: 101750
Buggy source:
/** 
 * Close the stream, flushing it first.  Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown.  Closing a previously-closed stream, however, has no effect.
 * @exception IOException If an I/O error occurs
 */
public void close() throws IOException {
  closed=true;
}

Fixed version (ground truth):
public void close(){
  closed=true;
}
Program: 101751
Project: 101751
Buggy source:
/** 
 * Setter for the main body of text
 */
public void setText(final InputStream in) throws IOException {
  Thread work=new Thread(new Runnable(){
    public void run(){
      try {
        InputStream pmin=new ProgressMonitorInputStream(TextViewPanel.this,"String_Node_Str",in);
        Reader rin=new InputStreamReader(pmin);
        final String data=StringUtil.read(rin);
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            setText(data);
          }
        }
);
      }
 catch (      IOException ex) {
        Reporter.informUser(TextViewPanel.this,ex);
      }
    }
  }
);
  work.start();
  work.setPriority(Thread.MIN_PRIORITY);
}

Fixed version (ground truth):
/** 
 * Setter for the main body of text
 */
public void setText(final InputStream in){
  Thread work=new Thread(new Runnable(){
    public void run(){
      try {
        InputStream pmin=new ProgressMonitorInputStream(TextViewPanel.this,"String_Node_Str",in);
        Reader rin=new InputStreamReader(pmin);
        final String data=StringUtil.read(rin);
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            setText(data);
          }
        }
);
      }
 catch (      IOException ex) {
        Reporter.informUser(TextViewPanel.this,ex);
      }
    }
  }
);
  work.start();
  work.setPriority(Thread.MIN_PRIORITY);
}
Program: 101752
Project: 101752
Buggy source:
public Object getProperty(String arg0) throws SAXNotRecognizedException, SAXNotSupportedException {
  return null;
}

Fixed version (ground truth):
public Object getProperty(String arg0){
  return null;
}
Program: 101753
Project: 101753
Buggy source:
public void parse(String arg0) throws IOException, SAXException {
  throw new SAXException("String_Node_Str");
}

Fixed version (ground truth):
public void parse(String arg0) throws SAXException {
  throw new SAXException("String_Node_Str");
}
Program: 101754
Project: 101754
Buggy source:
public boolean getFeature(String arg0) throws SAXNotRecognizedException, SAXNotSupportedException {
  return false;
}

Fixed version (ground truth):
public boolean getFeature(String arg0){
  return false;
}
Program: 101755
Project: 101755
Buggy source:
public void setFeature(String arg0,boolean arg1) throws SAXNotRecognizedException, SAXNotSupportedException {
}

Fixed version (ground truth):
public void setFeature(String arg0,boolean arg1){
}
Program: 101756
Project: 101756
Buggy source:
public void setProperty(String arg0,Object arg1) throws SAXNotRecognizedException, SAXNotSupportedException {
}

Fixed version (ground truth):
public void setProperty(String arg0,Object arg1){
}
Program: 101758
Project: 101758
Buggy source:
/** 
 * XML parse failed, so we can try getting rid of all the tags and having another go. We define a tag to start at a &lt; and end at the end of the next word (where a word is what comes in between spaces) that does not contain an = sign, or at a >, whichever is earlier.
 */
public static String cleanAllTags(String broken){
  String working=broken;
  allTags:   while (true) {
    int lt=working.indexOf('<');
    if (lt == -1) {
      break allTags;
    }
    int gt=working.indexOf('>',lt);
    String lton=working.substring(lt);
    String[] parts=StringUtils.split(lton,' ');
    int noeqword=-1;
    for (int i=0; i < parts.length; i++) {
      if (parts[i].indexOf('=') == -1) {
        noeqword=working.indexOf(parts[i]);
      }
    }
    if (gt == -1) {
      gt=Integer.MAX_VALUE;
    }
    if (noeqword == -1) {
      noeqword=Integer.MAX_VALUE;
    }
    int min=gt;
    if (noeqword < min) {
      min=noeqword;
    }
    if (working.length() < min) {
      min=working.length();
    }
    working=working.substring(lt,min);
  }
  return working;
}

Fixed version (ground truth):
/** 
 * XML parse failed, so we can try getting rid of all the tags and having another go. We define a tag to start at a &lt; and end at the end of the next word (where a word is what comes in between spaces) that does not contain an = sign, or at a >, whichever is earlier.
 */
public static String cleanAllTags(String broken){
  if (broken == null) {
    return null;
  }
  String working=broken;
  allTags:   while (true) {
    int lt=working.indexOf('<');
    if (lt == -1) {
      break allTags;
    }
    int gt=working.indexOf('>',lt);
    int noeqword=-1;
    int nextspc=working.indexOf(' ',lt);
    if (nextspc != -1) {
      String lton=working.substring(nextspc);
      String[] parts=StringUtils.split(lton,' ');
      for (int i=0; i < parts.length; i++) {
        if (parts[i].indexOf('=') == -1) {
          noeqword=working.indexOf(parts[i],lt) - 2;
        }
      }
    }
    if (gt == -1) {
      gt=Integer.MAX_VALUE;
    }
    if (noeqword == -1) {
      noeqword=Integer.MAX_VALUE;
    }
    int min=gt;
    if (noeqword < min) {
      min=noeqword;
    }
    if (working.length() < min) {
      min=working.length() - 1;
    }
    DataPolice.report("String_Node_Str" + working.substring(lt,min + 1));
    working=working.substring(0,lt) + working.substring(min + 1);
  }
  return working;
}
Program: 101759
Project: 101759
Buggy source:
/** 
 * A parse has failed so we can try to kill the entities and then have another go.
 */
public static String cleanAllEntities(String broken){
  String working=broken;
  allEntities:   while (true) {
    int amp=working.indexOf('&');
    if (amp == -1) {
      break allEntities;
    }
    int i=amp + 1;
    singleEntity:     while (true) {
      char c=working.charAt(i);
      if (c == ';') {
        working=working.substring(0,amp) + working.substring(i);
        break singleEntity;
      }
      if (!Character.isLetterOrDigit(c) && c != '-') {
        working=working.substring(0,amp) + working.substring(i);
        break singleEntity;
      }
      i++;
      if (i >= working.length()) {
        break singleEntity;
      }
    }
  }
  return working;
}

Fixed version (ground truth):
/** 
 * A parse has failed so we can try to kill the entities and then have another go.
 */
public static String cleanAllEntities(String broken){
  if (broken == null) {
    return null;
  }
  String working=broken;
  allEntities:   while (true) {
    int amp=working.indexOf('&');
    if (amp == -1) {
      break allEntities;
    }
    int i=amp + 1;
    singleEntity:     while (true) {
      if (i >= working.length()) {
        DataPolice.report("String_Node_Str" + working.substring(amp));
        working=working.substring(0,amp);
        break singleEntity;
      }
      char c=working.charAt(i);
      if (c == ';') {
        DataPolice.report("String_Node_Str" + working.substring(amp,i + 1));
        working=working.substring(0,amp) + working.substring(i + 1);
        break singleEntity;
      }
      if (!Character.isLetterOrDigit(c) && c != '-') {
        DataPolice.report("String_Node_Str" + working.substring(amp,i));
        working=working.substring(0,amp) + working.substring(i);
        break singleEntity;
      }
      i++;
    }
  }
  return working;
}
Program: 101760
Project: 101760
Buggy source:
public static Test suite(){
  TestSuite suite=new TestSuite();
  suite.addTest(org.crosswire.common.util.AllTests.suite());
  suite.addTest(org.crosswire.common.progress.AllTests.suite());
  return suite;
}

Fixed version (ground truth):
public static Test suite(){
  TestSuite suite=new TestSuite();
  suite.addTest(org.crosswire.common.util.AllTests.suite());
  suite.addTest(org.crosswire.common.progress.AllTests.suite());
  suite.addTest(org.crosswire.common.xml.AllTests.suite());
  return suite;
}
Program: 101761
Project: 101761
Buggy source:
/** 
 * Handle AWT exceptions
 */
public void handle(final Throwable ex){
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      ExceptionPane.showExceptionDialog(comp,ex);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Handle AWT exceptions
 */
public void handle(final Throwable ex){
  Reporter.informUser(this,ex);
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      ExceptionPane.showExceptionDialog(comp,ex);
    }
  }
);
}
Program: 101763
Project: 101763
Buggy source:
/** 
 * For a given word find a list of references to it.
 * @param word The text to search for
 * @return The references to the word
 */
public Passage findPassage(Search search) throws BookException {
  try {
    RemoteMethod method=new RemoteMethod(RemoteConstants.METHOD_FINDPASSAGE);
    method.addParam(RemoteConstants.PARAM_BIBLE,rbmd.getID());
    method.addParam(RemoteConstants.PARAM_FINDSTRING,search.getMatch());
    method.addParam(RemoteConstants.PARAM_FINDMATCH,"String_Node_Str" + search.isBestMatch());
    method.addParam(RemoteConstants.PARAM_FINDRANGE,search.getRange().getName());
    Document doc=remoter.execute(method);
    return Converter.convertDocumentToPassage(doc);
  }
 catch (  ConverterException ex) {
    throw new BookException("String_Node_Str",ex);
  }
catch (  RemoterException ex) {
    throw new BookException("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
/** 
 * For a given word find a list of references to it.
 * @param word The text to search for
 * @return The references to the word
 */
public Passage findPassage(Search search) throws BookException {
  try {
    RemoteMethod method=new RemoteMethod(RemoteConstants.METHOD_FINDPASSAGE);
    method.addParam(RemoteConstants.PARAM_BIBLE,rbmd.getID());
    method.addParam(RemoteConstants.PARAM_FINDSTRING,search.getMatch());
    method.addParam(RemoteConstants.PARAM_FINDMATCH,"String_Node_Str" + search.isBestMatch());
    method.addParam(RemoteConstants.PARAM_FINDRANGE,search.getRestriction().getName());
    Document doc=remoter.execute(method);
    return Converter.convertDocumentToPassage(doc);
  }
 catch (  ConverterException ex) {
    throw new BookException("String_Node_Str",ex);
  }
catch (  RemoterException ex) {
    throw new BookException("String_Node_Str",ex);
  }
}
Program: 101764
Project: 101764
Buggy source:
/** 
 * Retains only the Verses in this Passage that are contained in the specified Passage.  In other words, removes from this Passage all of its Verses that are not contained in the specified Passage
 * @param that Verses to be retained in this Passage.
 */
public void retainAll(Passage that){
  optimizeWrites();
  if (that instanceof BitwisePassage) {
    BitSet that_store=((BitwisePassage)that).store;
    store.and(that_store);
  }
 else {
    BitSet new_store=new BitSet(BibleInfo.versesInBible());
    Iterator it=that.verseIterator();
    while (it.hasNext()) {
      int ord=((Verse)it.next()).getOrdinal();
      if (store.get(ord))       new_store.set(ord);
    }
    store=new_store;
  }
  fireIntervalRemoved(this,null,null);
}

Fixed version (ground truth):
/** 
 * Retains only the Verses in this Passage that are contained in the specified Passage. In other words, removes from this Passage all of its Verses that are not contained in the specified Passage
 * @param that Verses to be retained in this Passage.
 */
public void retainAll(Passage that){
  optimizeWrites();
  if (that instanceof BitwisePassage) {
    BitSet that_store=((BitwisePassage)that).store;
    store.and(that_store);
  }
 else {
    BitSet new_store=new BitSet(BibleInfo.versesInBible());
    Iterator it=that.verseIterator();
    while (it.hasNext()) {
      int ord=((Verse)it.next()).getOrdinal();
      if (store.get(ord))       new_store.set(ord);
    }
    store=new_store;
  }
  fireIntervalRemoved(this,null,null);
}
Program: 101765
Project: 101765
Buggy source:
public void testWriteRetainAllCollection() throws Exception {
  temp=PassageFactory.createPassage("String_Node_Str");
  temp.retainAll(PassageFactory.createPassage("String_Node_Str"));
  assertEquals(temp.getName(),"String_Node_Str");
  temp.retainAll(PassageFactory.createPassage("String_Node_Str"));
  assertEquals(temp.getName(),"String_Node_Str");
  temp.retainAll(PassageFactory.createPassage("String_Node_Str"));
  assertEquals(temp.getName(),"String_Node_Str");
  temp.retainAll(PassageFactory.createPassage("String_Node_Str"));
  assertEquals(temp.getName(),"String_Node_Str");
}

Fixed version (ground truth):
public void testWriteRetainAllCollection() throws Exception {
  temp=PassageFactory.createPassage("String_Node_Str");
  temp.retainAll(PassageFactory.createPassage("String_Node_Str"));
  assertEquals(temp.getName(),"String_Node_Str");
  temp.retainAll(PassageFactory.createPassage("String_Node_Str"));
  assertEquals(temp.getName(),"String_Node_Str");
  temp.retainAll(PassageFactory.createPassage("String_Node_Str"));
  assertEquals(temp.getName(),"String_Node_Str");
  temp.retainAll(PassageFactory.createPassage("String_Node_Str"));
  assertEquals(temp.getName(),"String_Node_Str");
  temp.addAll(grace);
  assertEquals(temp.countVerses(),grace.countVerses());
  temp.retainAll(gen_rev);
  assertEquals(temp,grace);
  temp.retainAll(PassageFactory.createPassage("String_Node_Str"));
  assertEquals(temp.countVerses(),10);
  temp.retainAll(PassageFactory.createPassage("String_Node_Str"));
  assertEquals(temp.countVerses(),4);
  temp.retainAll(PassageFactory.createPassage("String_Node_Str"));
  assertEquals(temp.getName(),"String_Node_Str");
}
Program: 101767
Project: 101767
Buggy source:
/** 
 * Someone pressed return in the search area
 */
protected void doSearchAction(){
  try {
    String param=txt_search.getText();
    Search search=new Search(param,false);
    if (chk_srestrict.isSelected()) {
      Passage restrict=PassageFactory.createPassage(txt_srestrict.getText());
      search.setRange(restrict);
    }
    Bible version=(Bible)mdl_versn.getSelectedBookMetaData().getBook();
    Passage ref=version.findPassage(search);
    txt_passg.setText(ref.getName());
    updateDisplay();
    setDefaultName(param);
  }
 catch (  Exception ex) {
    Reporter.informUser(this,ex);
  }
}

Fixed version (ground truth):
/** 
 * Someone pressed return in the search area
 */
protected void doSearchAction(){
  try {
    String param=txt_search.getText();
    Search search=new Search(param,false);
    if (chk_srestrict.isSelected()) {
      Passage restrict=PassageFactory.createPassage(txt_srestrict.getText());
      search.setRestriction(restrict);
    }
    Bible version=(Bible)mdl_versn.getSelectedBookMetaData().getBook();
    Passage ref=version.findPassage(search);
    txt_passg.setText(ref.getName());
    setDefaultName(param);
    updateDisplay();
    setCurrentAction(PASSAGE);
  }
 catch (  Exception ex) {
    Reporter.informUser(this,ex);
  }
}
Program: 101768
Project: 101768
Buggy source:
/** 
 * Inform the command listeners
 */
protected void fireCommandMade(DisplaySelectEvent ev){
  if (commandListeners != null) {
    Vector listeners=commandListeners;
    int count=listeners.size();
    for (int i=0; i < count; i++) {
      ((DisplaySelectListener)listeners.elementAt(i)).passageSelected(ev);
    }
  }
}

Fixed version (ground truth):
/** 
 * Inform the command listeners
 */
protected void fireCommandMade(DisplaySelectEvent ev){
  if (listeners != null) {
    for (int i=0; i < listeners.size(); i++) {
      DisplaySelectListener li=(DisplaySelectListener)listeners.get(i);
      li.passageSelected(ev);
    }
  }
}
Program: 101769
Project: 101769
Buggy source:
/** 
 * What is the currently displayed action?
 * @param action one of the constants PASSAGE, SEARCH or MATCH;
 */
public void setCurrentAction(String action){
  lay_cards.show(pnl_cards,action);
  if (action == PASSAGE) {
    rdo_passg.setSelected(true);
  }
 else   if (action == SEARCH) {
    rdo_search.setSelected(true);
  }
 else   if (action == MATCH) {
    rdo_match.setSelected(true);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * What is the currently displayed action?
 * @param action one of the constants PASSAGE, SEARCH or MATCH;
 */
private void setCurrentAction(String action){
  lay_cards.show(pnl_cards,action);
  if (action == PASSAGE) {
    rdo_passg.setSelected(true);
  }
 else   if (action == SEARCH) {
    rdo_search.setSelected(true);
  }
 else   if (action == MATCH) {
    rdo_match.setSelected(true);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  adjustFocus();
}
Program: 101770
Project: 101770
Buggy source:
/** 
 * Add a command listener
 */
public synchronized void removeCommandListener(DisplaySelectListener li){
  if (commandListeners != null && commandListeners.contains(li)) {
    Vector v=(Vector)commandListeners.clone();
    v.removeElement(li);
    commandListeners=v;
  }
}

Fixed version (ground truth):
/** 
 * Remove a command listener
 */
public synchronized void removeCommandListener(DisplaySelectListener li){
  if (listeners != null && listeners.contains(li)) {
    List temp=new ArrayList();
    temp.addAll(listeners);
    temp.remove(li);
    listeners=temp;
  }
}
Program: 101771
Project: 101771
Buggy source:
/** 
 * Someone pressed return in the passage area
 */
protected void doPassageAction(){
  updateDisplay();
  setDefaultName(txt_passg.getText());
}

Fixed version (ground truth):
/** 
 * Someone pressed return in the passage area
 */
protected void doPassageAction(){
  setDefaultName(txt_passg.getText());
  updateDisplay();
}
Program: 101772
Project: 101772
Buggy source:
/** 
 * Someone pressed return in the search area
 */
protected void doMatchAction(){
  try {
    String param=txt_match.getText();
    Search search=new Search(param,true);
    if (chk_mrestrict.isSelected()) {
      Passage restrict=PassageFactory.createPassage(txt_mrestrict.getText());
      search.setRange(restrict);
    }
    Bible version=(Bible)mdl_versn.getSelectedBookMetaData().getBook();
    Passage ref=version.findPassage(search);
    if (ref instanceof PassageTally) {
      PassageTally tally=(PassageTally)ref;
      tally.setOrdering(PassageTally.ORDER_TALLY);
      tally.trimRanges(20);
    }
    txt_passg.setText(ref.getName());
    updateDisplay();
    setDefaultName(param);
  }
 catch (  Exception ex) {
    Reporter.informUser(this,ex);
  }
}

Fixed version (ground truth):
/** 
 * Someone pressed return in the search area
 */
protected void doMatchAction(){
  try {
    String param=txt_match.getText();
    Search search=new Search(param,true);
    if (chk_mrestrict.isSelected()) {
      Passage restrict=PassageFactory.createPassage(txt_mrestrict.getText());
      search.setRestriction(restrict);
    }
    Bible version=(Bible)mdl_versn.getSelectedBookMetaData().getBook();
    Passage ref=version.findPassage(search);
    if (ref instanceof PassageTally) {
      PassageTally tally=(PassageTally)ref;
      tally.setOrdering(PassageTally.ORDER_TALLY);
      tally.trimRanges(20);
    }
    txt_passg.setText(ref.getName());
    setDefaultName(param);
    updateDisplay();
    setCurrentAction(PASSAGE);
  }
 catch (  Exception ex) {
    Reporter.informUser(this,ex);
  }
}
Program: 101773
Project: 101773
Buggy source:
/** 
 * Remove a command listener
 */
public synchronized void addCommandListener(DisplaySelectListener li){
  Vector v=commandListeners == null ? new Vector(2) : (Vector)commandListeners.clone();
  if (!v.contains(li)) {
    v.addElement(li);
    commandListeners=v;
  }
}

Fixed version (ground truth):
/** 
 * Add a command listener
 */
public synchronized void addCommandListener(DisplaySelectListener li){
  List temp=new ArrayList(2);
  if (listeners != null) {
    temp.addAll(listeners);
  }
  if (!temp.contains(li)) {
    temp.add(li);
    listeners=temp;
  }
}
Program: 101774
Project: 101774
Buggy source:
/** 
 * Inform the version listeners
 */
protected void fireVersionChanged(DisplaySelectEvent ev){
  if (versionListeners != null) {
    Vector listeners=versionListeners;
    int count=listeners.size();
    for (int i=0; i < count; i++) {
      ((DisplaySelectListener)listeners.elementAt(i)).bookChosen(ev);
    }
  }
}

Fixed version (ground truth):
/** 
 * Inform the version listeners
 */
protected void fireVersionChanged(DisplaySelectEvent ev){
  if (listeners != null) {
    int count=listeners.size();
    for (int i=0; i < count; i++) {
      ((DisplaySelectListener)listeners.get(i)).bookChosen(ev);
    }
  }
}
Program: 101776
Project: 101776
Buggy source:
public void testGetBibles() throws Exception {
  List lbmds=Books.getBooks(BookFilters.getFaster(Books.SPEED_SLOWEST));
  BibleMetaData[] names1=(BibleMetaData[])lbmds.toArray(new BibleMetaData[lbmds.size()]);
  RemoteMethod method=new RemoteMethod(RemoteConstants.METHOD_GETBIBLES);
  Document doc=remote.execute(method);
  BibleMetaData[] names2=Converter.convertDocumentToBibleMetaDatas(doc,new FixtureRemoter(),Books.SPEED_INACCURATE);
  assertEquals(names1.length,names2.length);
  for (int i=0; i < names1.length; i++) {
    assertEquals(names1[i].getName(),names2[i].getName());
  }
}

Fixed version (ground truth):
public void testGetBibles() throws Exception {
  BookFilter filter=BookFilters.both(BookFilters.getFaster(Books.SPEED_SLOWEST),BookFilters.getBibles());
  List lbmds=Books.getBooks(filter);
  BibleMetaData[] names1=(BibleMetaData[])lbmds.toArray(new BibleMetaData[lbmds.size()]);
  RemoteMethod method=new RemoteMethod(RemoteConstants.METHOD_GETBIBLES);
  Document doc=remote.execute(method);
  BibleMetaData[] names2=Converter.convertDocumentToBibleMetaDatas(doc,new FixtureRemoter(),Books.SPEED_INACCURATE);
  assertEquals(names1.length,names2.length);
  for (int i=0; i < names1.length; i++) {
    assertEquals(names1[i].getName(),names2[i].getName());
  }
}
Program: 101777
Project: 101777
Buggy source:
/** 
 * Something has happened. We need to tell the user or someone. <p>Maybe we should have an extra parameter (or even several versions of this method like log*()) that describes the severity of the message. A Sw*ng listener could use this to decide the icon in the OptionPane for example.</p>
 * @param source The cause of the message, a Component if possible.
 * @param message The message to pass to the user
 */
public static void informUser(String message){
  fireCapture(new ReporterEvent(message));
}

Fixed version (ground truth):
/** 
 * Something has happened. We need to tell the user or someone. <p>Maybe we should have an extra parameter (or even several versions of this method like log*()) that describes the severity of the message. A Sw*ng listener could use this to decide the icon in the OptionPane for example.</p>
 * @param source The cause of the message, a Component if possible.
 * @param message The message to pass to the user
 */
public static void informUser(String message){
  log.debug(message);
  fireCapture(new ReporterEvent(message));
}
Program: 101778
Project: 101778
Buggy source:
/** 
 * Log a message
 * @param source Where the message comes from
 * @param message The text message
 */
protected static void fireCapture(ReporterEvent ev){
  try {
    Object[] listeners=inform_list.getListenerList();
    for (int i=listeners.length - 2; i >= 0; i-=2) {
      if (listeners[i] == ReporterListener.class) {
        ReporterListener li=(ReporterListener)listeners[i + 1];
        try {
          if (ev.getException() != null)           li.reportException(ev);
 else           li.reportMessage(ev);
        }
 catch (        Throwable ex) {
          if (ex instanceof ThreadDeath)           throw (ThreadDeath)ex;
          inform_list.remove(CaptureListener.class,li);
          log.warn("String_Node_Str",ex);
        }
      }
    }
  }
 catch (  Exception ex) {
    System.out.println(ex);
  }
}

Fixed version (ground truth):
/** 
 * Log a message
 * @param source Where the message comes from
 * @param message The text message
 */
protected static void fireCapture(ReporterEvent ev){
  try {
    Object[] listeners=inform_list.getListenerList();
    if (listeners.length == 0) {
      log.warn("String_Node_Str" + ev.getMessage());
    }
    for (int i=listeners.length - 2; i >= 0; i-=2) {
      if (listeners[i] == ReporterListener.class) {
        ReporterListener li=(ReporterListener)listeners[i + 1];
        try {
          if (ev.getException() != null)           li.reportException(ev);
 else           li.reportMessage(ev);
        }
 catch (        Throwable ex) {
          if (ex instanceof ThreadDeath)           throw (ThreadDeath)ex;
          inform_list.remove(CaptureListener.class,li);
          log.warn("String_Node_Str",ex);
        }
      }
    }
  }
 catch (  Exception ex) {
    System.out.println(ex);
  }
}
Program: 101779
Project: 101779
Buggy source:
/** 
 * Generic resource URL fetcher. One way or the other we'll find it!
 * @param search The name of the resource (without a leading /) to find
 * @return A URL of the found resource or null if we couldn't find one.
 */
public URL getResource(String search){
  URL reply=getClass().getResource(search);
  if (reply == null)   reply=getClass().getResource("String_Node_Str" + search);
  if (reply == null)   reply=getClass().getResource("String_Node_Str" + search);
  if (reply == null)   reply=getClass().getClassLoader().getResource(search);
  if (reply == null)   reply=getClass().getClassLoader().getResource("String_Node_Str" + search);
  if (reply == null)   reply=getClass().getClassLoader().getSystemResource(search);
  if (reply == null)   reply=getClass().getClassLoader().getSystemResource("String_Node_Str" + search);
  return reply;
}

Fixed version (ground truth):
/** 
 * Generic resource URL fetcher. One way or the other we'll find it!
 * @param search The name of the resource (without a leading /) to find
 * @return A URL of the found resource or null if we couldn't find one.
 */
public URL getResource(String search){
  URL reply=getClass().getResource(search);
  if (reply == null)   reply=getClass().getResource("String_Node_Str" + search);
  if (reply == null)   reply=getClass().getClassLoader().getResource(search);
  if (reply == null)   reply=getClass().getClassLoader().getResource("String_Node_Str" + search);
  if (reply == null)   reply=getClass().getClassLoader().getSystemResource(search);
  if (reply == null)   reply=getClass().getClassLoader().getSystemResource("String_Node_Str" + search);
  return reply;
}
Program: 101780
Project: 101780
Buggy source:
/** 
 * Get a list of the Books available from the driver
 * @return an array of book names
 */
public String[] getBibleNames(){
  if (dir == null)   return new String[0];
  try {
    if (dir.getProtocol().equals("String_Node_Str")) {
      File fdir=new File(dir.getFile());
      if (!fdir.isDirectory()) {
        return new String[0];
      }
      return fdir.list(new CustomFilenameFilter());
    }
 else {
      URL search=NetUtil.lengthenURL(dir,"String_Node_Str");
      InputStream in=search.openStream();
      String contents=StringUtil.read(new InputStreamReader(in));
      return StringUtil.tokenize(contents,"String_Node_Str");
    }
  }
 catch (  IOException ex) {
    log.warn("String_Node_Str" + ex);
    return new String[0];
  }
}

Fixed version (ground truth):
/** 
 * Get a list of the Books available from the driver
 * @return an array of book names
 */
public String[] getBibleNames(){
  if (dir == null)   return new String[0];
  try {
    if (dir.getProtocol().equals("String_Node_Str")) {
      File fdir=new File(dir.getFile());
      if (!fdir.isDirectory()) {
        return new String[0];
      }
      return fdir.list(new CustomFilenameFilter());
    }
 else {
      URL search=NetUtil.lengthenURL(dir,"String_Node_Str");
      InputStream in=search.openStream();
      String contents=StringUtil.read(new InputStreamReader(in));
      String[] names=StringUtil.tokenize(contents,"String_Node_Str");
      for (int i=0; i < names.length; i++) {
        names[i]=names[i].trim();
      }
      return names;
    }
  }
 catch (  IOException ex) {
    log.warn("String_Node_Str" + ex);
    return new String[0];
  }
}
Program: 101782
Project: 101782
Buggy source:
private Object tryResolveObject(final ObjectWithPath<Object> objectWithPath){
  try {
    return resolveObject(objectWithPath);
  }
 catch (  final IllegalStateException e) {
    log.warn(e);
    return objectWithPath.getObject();
  }
}

Fixed version (ground truth):
private Object tryResolveObject(final ObjectWithPath<? extends Object> objectWithPath){
  try {
    return resolveObject(objectWithPath);
  }
 catch (  final IllegalStateException e) {
    log.warn(e);
    return objectWithPath.getObject();
  }
}
Program: 101783
Project: 101783
Buggy source:
private Object resolveObject(final ObjectWithPath<Object> objectWithPath){
  final Object object=objectWithPath.getObject();
  final StringBuilder path=new StringBuilder();
  path.append(objectWithPath.getPath());
  path.append("String_Node_Str");
  path.append("String_Node_Str" + modelUtil.getGroupId(object) + "String_Node_Str");
  path.append("String_Node_Str" + modelUtil.getArtifactId(object) + "String_Node_Str");
  final String type=modelUtil.tryGetType(object);
  if (type != null) {
    path.append("String_Node_Str" + type + "String_Node_Str");
  }
  final String classifier=modelUtil.tryGetClassifier(object);
  if (classifier != null) {
    path.append("String_Node_Str" + classifier + "String_Node_Str");
  }
  path.append("String_Node_Str");
  final Model model=objectWithPath.getProject().getModel();
  final Collection<Object> objects=expressionEvaluator.getPath(model,path.toString());
  if (objects.isEmpty()) {
    throw new IllegalStateException("String_Node_Str" + object + "String_Node_Str"+ path);
  }
 else   if (objects.size() > 1) {
    throw new IllegalStateException("String_Node_Str" + objects.size() + "String_Node_Str"+ path);
  }
 else {
    return objects.iterator().next();
  }
}

Fixed version (ground truth):
/** 
 * This uses the path of an object that was found in the "original model", and tries to find the same object in the "model".  The "model" has had properties replaced with values, so this is how we find the resolved version of the object.
 */
private Object resolveObject(final ObjectWithPath<? extends Object> objectWithPath){
  final Object object=objectWithPath.getObject();
  final StringBuilder path=new StringBuilder();
  path.append(objectWithPath.getPath());
  path.append("String_Node_Str");
  path.append("String_Node_Str" + modelUtil.getGroupId(object) + "String_Node_Str");
  path.append("String_Node_Str" + modelUtil.getArtifactId(object) + "String_Node_Str");
  final String type=modelUtil.tryGetType(object);
  if (type != null) {
    path.append("String_Node_Str" + type + "String_Node_Str");
  }
  final String classifier=modelUtil.tryGetClassifier(object);
  if (classifier != null) {
    path.append("String_Node_Str" + classifier + "String_Node_Str");
  }
  path.append("String_Node_Str");
  final Model model=objectWithPath.getProject().getModel();
  final Collection<Object> objects=expressionEvaluator.getPath(model,path.toString());
  if (objects.isEmpty()) {
    throw new IllegalStateException("String_Node_Str" + object + "String_Node_Str"+ path);
  }
 else   if (objects.size() > 1) {
    throw new IllegalStateException("String_Node_Str" + objects.size() + "String_Node_Str"+ path);
  }
 else {
    return objects.iterator().next();
  }
}
Program: 101784
Project: 101784
Buggy source:
protected void checkForRedundantVersions(final MavenProject mavenProject,final ResultCollector resultCollector,final ObjectWithPath<Object> object,final ObjectWithPath<Object> inheritedObject,final String dependencyDescription,final String inheritedDescription){
  final Object modelObject=object.getObject();
  final Object resolvedModelObject=tryResolveObject(object);
  if (isExcluded(resolvedModelObject)) {
    return;
  }
  final String version=resolveVersion(modelObject,resolvedModelObject);
  final String inheritedVersion=modelUtil.getVersion(tryResolveObject(inheritedObject));
  if (version != null && inheritedVersion != null && inheritedVersion.equals(version)) {
    final InputLocation location=modelUtil.getLocation(modelObject,"String_Node_Str");
    resultCollector.addViolation(mavenProject,this,dependencyDescription + "String_Node_Str" + modelUtil.getKey(modelObject)+ "String_Node_Str"+ version+ "String_Node_Str"+ inheritedDescription,location);
  }
}

Fixed version (ground truth):
protected void checkForRedundantVersions(final MavenProject mavenProject,final ResultCollector resultCollector,final ObjectWithPath<? extends Object> object,final ObjectWithPath<? extends Object> inheritedObject,final String dependencyDescription,final String inheritedDescription){
  final Object modelObject=object.getObject();
  final Object resolvedModelObject=tryResolveObject(object);
  if (isExcluded(resolvedModelObject)) {
    return;
  }
  final String version=resolveVersion(modelObject,resolvedModelObject);
  final String inheritedVersion=modelUtil.getVersion(tryResolveObject(inheritedObject));
  if (version != null && inheritedVersion != null && inheritedVersion.equals(version)) {
    final InputLocation location=modelUtil.getLocation(modelObject,"String_Node_Str");
    resultCollector.addViolation(mavenProject,this,dependencyDescription + "String_Node_Str" + modelUtil.getKey(modelObject)+ "String_Node_Str"+ version+ "String_Node_Str"+ inheritedDescription,location);
  }
}
Program: 101786
Project: 101786
Buggy source:
public ExtDependency findInheritedDependency(final MavenProject mavenProject,final Dependency dependency){
  final MavenProject parent=mavenProject.getParent();
  if (parent != null) {
    final Map<String,Dependency> dependencies=mapByManagementKey(expressionEvaluator.<Dependency>getPath(parent.getOriginalModel(),"String_Node_Str"));
    final Map<String,Dependency> managedDependencies=mapByManagementKey(expressionEvaluator.<Dependency>getPath(parent.getOriginalModel(),"String_Node_Str"));
    final Dependency parentDependency=dependencies.get(dependency.getManagementKey());
    if (parentDependency != null) {
      return new ExtDependency(parent,parentDependency);
    }
    final Dependency parentManagedDependency=managedDependencies.get(dependency.getManagementKey());
    if (parentManagedDependency != null) {
      return new ExtDependency(parent,parentManagedDependency);
    }
    return findInheritedDependency(parent,dependency);
  }
  return null;
}

Fixed version (ground truth):
public ObjectWithPath<ExtDependency> findInheritedDependency(final MavenProject mavenProject,final Dependency dependency){
  final MavenProject parent=mavenProject.getParent();
  if (parent != null) {
    final Map<String,Dependency> dependencies=mapByManagementKey(expressionEvaluator.<Dependency>getPath(parent.getOriginalModel(),"String_Node_Str"));
    final Map<String,Dependency> managedDependencies=mapByManagementKey(expressionEvaluator.<Dependency>getPath(parent.getOriginalModel(),"String_Node_Str"));
    final Dependency parentDependency=dependencies.get(dependency.getManagementKey());
    if (parentDependency != null) {
      return new ObjectWithPath<ExtDependency>(new ExtDependency(parent,parentDependency),parent,"String_Node_Str");
    }
    final Dependency parentManagedDependency=managedDependencies.get(dependency.getManagementKey());
    if (parentManagedDependency != null) {
      return new ObjectWithPath<ExtDependency>(new ExtDependency(parent,parentManagedDependency),parent,"String_Node_Str");
    }
    return findInheritedDependency(parent,dependency);
  }
  return null;
}
Program: 101787
Project: 101787
Buggy source:
private void addEmptySlot(){
  if (inventory.size() > 35) {
    return;
  }
  List<InventorySlot> outInventory=new ArrayList<InventorySlot>();
  for (int i=0; i < tempInventory.size(); i++) {
    if (tempInventory.get(i).getSlot() < 9) {
      outInventory.add(tempInventory.get(i));
    }
  }
  InventorySlot slot=new InventorySlot((byte)(inventory.size() + 9),new ItemStack((short)0,(short)0,(short)0));
  inventory.add(slot);
  inventoryListAdapter.notifyDataSetChanged();
  outInventory.addAll(inventory);
  EditorActivity.level.getPlayer().setInventory(outInventory);
  EditorActivity.save(this);
}

Fixed version (ground truth):
private void addEmptySlot(){
  if (inventory.size() > 35) {
    return;
  }
  List<InventorySlot> outInventory=new ArrayList<InventorySlot>();
  for (int i=0; i < tempInventory.size(); i++) {
    if (tempInventory.get(i).getSlot() < 9) {
      outInventory.add(tempInventory.get(i));
    }
  }
  InventorySlot slot=new InventorySlot((byte)(inventory.size() + 9),new ItemStack((short)0,(short)0,(short)0));
  alignSlots();
  inventory.add(slot);
  inventoryListAdapter.notifyDataSetChanged();
  outInventory.addAll(inventory);
  EditorActivity.level.getPlayer().setInventory(outInventory);
  EditorActivity.save(this);
}
Program: 101788
Project: 101788
Buggy source:
public void log(String message,int i){
  if (getConfiguration().logConsole()) {
    Bukkit.getConsoleSender().sendMessage(ChatColor.RED + message);
  }
  if (i == 0 && getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH) {
    fileLog(message);
  }
 else   if (getConfiguration().getFileLogLevel() != 0) {
    fileLog(message);
  }
  logs.add(ChatColor.stripColor(message));
}

Fixed version (ground truth):
public void log(String message,int i){
  if (i != 1 && getConfiguration().logConsole()) {
    Bukkit.getConsoleSender().sendMessage(ChatColor.RED + message);
  }
  if (i == 0 && getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH) {
    fileLog(message);
  }
 else   if (getConfiguration().getFileLogLevel() != 0) {
    fileLog(message);
  }
  logs.add(ChatColor.stripColor(message));
}