nus-yam/ex-repair huggingface dataset:
Program: 5117
Project: 5117
Buggy source:
public HTTPDownloader(String protocal,String host,int port,int index,String file,ConnectionManager m,byte[] guid){
  _filename=file;
  _amountRead=0;
  _sizeOfFile=-1;
  _socket=null;
  _manager=m;
  _callback=_manager.getCallback();
  _downloadDir="String_Node_Str";
  URLConnection conn;
  String furl="String_Node_Str" + String.valueOf(index) + "String_Node_Str"+ file;
  try {
    URL url=new URL(protocal,host,port,furl);
    conn=url.openConnection();
  }
 catch (  java.net.MalformedURLException e) {
    sendPushRequest(host,index,port,guid);
    _callback.error(ActivityCallback.ERROR_5);
    return;
  }
catch (  IOException e) {
    sendPushRequest(host,index,port,guid);
    _callback.error(ActivityCallback.ERROR_6);
    return;
  }
  try {
    _istream=conn.getInputStream();
    _br=new ByteReader(_istream);
  }
 catch (  NoRouteToHostException e) {
    System.out.println("String_Node_Str");
    _callback.error(ActivityCallback.ERROR_13);
    return;
  }
catch (  IOException e) {
    e.printStackTrace();
    sendPushRequest(host,index,port,guid);
    return;
  }
}

Fixed version (ground truth):
public HTTPDownloader(String protocal,String host,int port,int index,String file,ConnectionManager m,byte[] guid){
  _okay=false;
  _filename=file;
  _amountRead=0;
  _sizeOfFile=-1;
  _socket=null;
  _manager=m;
  _callback=_manager.getCallback();
  _downloadDir="String_Node_Str";
  URLConnection conn;
  String furl="String_Node_Str" + String.valueOf(index) + "String_Node_Str"+ file;
  try {
    URL url=new URL(protocal,host,port,furl);
    conn=url.openConnection();
  }
 catch (  java.net.MalformedURLException e) {
    sendPushRequest(host,index,port,guid);
    _callback.error(ActivityCallback.ERROR_5);
    return;
  }
catch (  IOException e) {
    sendPushRequest(host,index,port,guid);
    _callback.error(ActivityCallback.ERROR_6);
    return;
  }
catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
    return;
  }
  try {
    _istream=conn.getInputStream();
    _br=new ByteReader(_istream);
  }
 catch (  NoRouteToHostException e) {
    System.out.println("String_Node_Str");
    _callback.error(ActivityCallback.ERROR_13);
    return;
  }
catch (  IOException e) {
    e.printStackTrace();
    sendPushRequest(host,index,port,guid);
    return;
  }
catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
    return;
  }
  _okay=true;
}
Program: 5118
Project: 5118
Buggy source:
public void doDownload(){
  SettingsManager set=SettingsManager.instance();
  _downloadDir=set.getSaveDirectory();
  String pathname=_downloadDir + _filename;
  System.out.println(pathname);
  try {
    _fos=new FileOutputStream(pathname);
  }
 catch (  FileNotFoundException e) {
    System.out.println("String_Node_Str");
  }
catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  readHeader();
  int c=-1;
  byte[] buf=new byte[1024];
  while (true) {
    try {
      c=_br.read(buf);
    }
 catch (    Exception e) {
      System.out.print("String_Node_Str");
    }
    if (c == -1)     break;
    try {
      _fos.write(buf,0,c);
    }
 catch (    Exception e) {
      System.out.print("String_Node_Str");
    }
    _amountRead+=c;
  }
  try {
    _br.close();
    _fos.close();
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
public void doDownload(){
  SettingsManager set=SettingsManager.instance();
  _downloadDir=set.getSaveDirectory();
  String pathname=_downloadDir + _filename;
  System.out.println(pathname);
  try {
    _fos=new FileOutputStream(pathname);
  }
 catch (  FileNotFoundException e) {
    System.out.println("String_Node_Str");
  }
catch (  Exception e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  readHeader();
  int c=-1;
  byte[] buf=new byte[1024];
  while (true) {
    try {
      c=_br.read(buf);
    }
 catch (    Exception e) {
      System.out.println("String_Node_Str");
      return;
    }
    if (c == -1)     break;
    try {
      _fos.write(buf,0,c);
    }
 catch (    Exception e) {
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str");
      e.printStackTrace();
      return;
    }
    _amountRead+=c;
    System.out.println("String_Node_Str" + _amountRead);
    System.out.println("String_Node_Str" + _sizeOfFile);
    double percent=_amountRead / _sizeOfFile;
    System.out.println("String_Node_Str" + percent);
    System.out.println("String_Node_Str");
  }
  try {
    _br.close();
    _fos.close();
  }
 catch (  IOException e) {
  }
}
Program: 5119
Project: 5119
Buggy source:
public void run(){
  _callback.addDownload(this);
  doDownload();
  _callback.removeDownload(this);
}

Fixed version (ground truth):
public void run(){
  if (_okay) {
    _callback.addDownload(this);
    doDownload();
    _callback.removeDownload(this);
  }
}
Program: 5120
Project: 5120
Buggy source:
public void readHeader(){
  String str=null;
  while (true) {
    str=_br.readLine();
    System.out.println(str);
    if (str.indexOf("String_Node_Str") != -1) {
      String sub=str.substring(15);
      sub.trim();
      _sizeOfFile=java.lang.Integer.parseInt(sub);
      str=_br.readLine();
      System.out.println(str);
      break;
    }
  }
}

Fixed version (ground truth):
public void readHeader(){
  String str=null;
  int flag=0;
  while (true) {
    str=_br.readLine();
    System.out.println(str);
    if (str.indexOf("String_Node_Str") != -1) {
      String sub=str.substring(15);
      sub.trim();
      System.out.println("String_Node_Str" + str + "String_Node_Str");
      System.out.println("String_Node_Str" + sub + "String_Node_Str");
      try {
        _sizeOfFile=java.lang.Integer.parseInt(sub);
      }
 catch (      NumberFormatException e) {
        System.out.println("String_Node_Str");
        return;
      }
      flag=1;
      str=_br.readLine();
      System.out.println(str);
      break;
    }
  }
  if (flag == 0) {
    System.out.println("String_Node_Str");
    System.out.println("String_Node_Str");
    System.out.println("String_Node_Str");
  }
}
Program: 5121
Project: 5121
Buggy source:
/** 
 * subclasses must override this method 
 */
protected ArrayList search(String query){
  ArrayList response_list=new ArrayList();
  try {
    pattern=compiler.compile(query);
  }
 catch (  MalformedPatternException e) {
    for (int i=0; i < _numFiles; i++) {
      FileDesc desc=(FileDesc)_files.get(i);
      String file_name=desc._name;
      if (file_name.indexOf(query) != -1)       response_list.add(_files.get(i));
    }
  }
  for (int i=0; i < _numFiles; i++) {
    FileDesc desc=(FileDesc)_files.get(i);
    String file_name=desc._name;
    input=new PatternMatcherInput(file_name);
    if (matcher.contains(input,pattern))     response_list.add(_files.get(i));
  }
  return response_list;
}

Fixed version (ground truth):
/** 
 * subclasses must override this method 
 */
protected ArrayList search(String query){
  ArrayList response_list=new ArrayList();
  try {
    try {
      pattern=compiler.compile(query);
    }
 catch (    MalformedPatternException e) {
      for (int i=0; i < _numFiles; i++) {
        FileDesc desc=(FileDesc)_files.get(i);
        String file_name=desc._name;
        if (file_name.indexOf(query) != -1)         response_list.add(_files.get(i));
      }
    }
    for (int i=0; i < _numFiles; i++) {
      FileDesc desc=(FileDesc)_files.get(i);
      String file_name=desc._name;
      input=new PatternMatcherInput(file_name);
      if (matcher.contains(input,pattern))       response_list.add(_files.get(i));
    }
  }
 catch (  Exception e2) {
    System.out.println("String_Node_Str" + e2);
  }
  return response_list;
}
Program: 5122
Project: 5122
Buggy source:
/** 
 * Create a hex version of a GUID for compact display and storage Note that the client guid should be read in with the  Integer.parseByte(String s, int radix)  call like this in reverse
 */
public String toHexString(){
  StringBuffer buf=new StringBuffer();
  int val;
  for (int i=0; i < SZ; i+=4) {
    val=bytes[i];
    val=(val * 256) + bytes[i + 1];
    val=(val * 256) + bytes[i + 2];
    val=(val * 256) + bytes[i + 3];
    buf.append(Integer.toHexString(val));
  }
  return buf.toString();
}

Fixed version (ground truth):
/** 
 * Create a hex version of a GUID for compact display and storage Note that the client guid should be read in with the  Integer.parseByte(String s, int radix)  call like this in reverse
 */
public String toHexString(){
  StringBuffer buf=new StringBuffer();
  String str;
  int val;
  for (int i=0; i < SZ; i+=4) {
    val=bytes[i];
    val=(val * 256) + bytes[i + 1];
    val=(val * 256) + bytes[i + 2];
    val=(val * 256) + bytes[i + 3];
    str=Integer.toHexString(val);
    while (str.length() < 8)     str="String_Node_Str" + str;
    buf.append(str);
  }
  return buf.toString();
}
Program: 5123
Project: 5123
Buggy source:
public void doDownload(){
  readHeader();
  try {
    if (_sizeOfFile != -1) {
      SettingsManager set=SettingsManager.instance();
      _downloadDir=set.getSaveDirectory();
      String pathname=_downloadDir + _filename;
      System.out.println("String_Node_Str" + pathname);
      int c=-1;
      _bis=new BufferedInputStream(_istream);
      FileOutputStream fos=new FileOutputStream(pathname);
      byte[] buf=new byte[1024];
      while (true) {
        c=_istream.read(buf);
        if (c == -1)         break;
        fos.write(buf,0,c);
        _amountRead+=c;
      }
      fos.close();
      System.out.println("String_Node_Str" + _sizeOfFile);
    }
  }
 catch (  Exception e) {
    _callback.error(ActivityCallback.ERROR_8);
    System.out.println("String_Node_Str" + e + "String_Node_Str");
  }
}

Fixed version (ground truth):
public void doDownload(){
  readHeader();
  try {
    if (_sizeOfFile != -1) {
      SettingsManager set=SettingsManager.instance();
      _downloadDir=set.getSaveDirectory();
      String pathname=_downloadDir + "String_Node_Str" + _filename;
      System.out.println("String_Node_Str" + pathname);
      int c=-1;
      _bis=new BufferedInputStream(_istream);
      FileOutputStream fos=new FileOutputStream(pathname);
      byte[] buf=new byte[1024];
      while (true) {
        c=_istream.read(buf);
        if (c == -1)         break;
        fos.write(buf,0,c);
        _amountRead+=c;
      }
      fos.close();
      System.out.println("String_Node_Str" + _sizeOfFile);
    }
  }
 catch (  Exception e) {
    _callback.error(ActivityCallback.ERROR_8);
    System.out.println("String_Node_Str" + e + "String_Node_Str");
  }
}
Program: 5124
Project: 5124
Buggy source:
public void doSchmownload(){
  System.out.println("String_Node_Str");
  readHeader();
  try {
    if (_sizeOfFile != -1) {
      SettingsManager set=SettingsManager.instance();
      _downloadDir=set.getSaveDirectory();
      String pathname=_downloadDir + _filename;
      System.out.println("String_Node_Str" + pathname);
      File myFile=new File(pathname);
      FileOutputStream fos=new FileOutputStream(myFile);
      BufferedOutputStream bos=new BufferedOutputStream(fos);
      int count=0;
      int c=-1;
      byte[] buf=new byte[MAX_BUFF];
      while (true) {
        int available=_bis.available();
        System.out.println("String_Node_Str" + available);
        int amount=Math.min(MAX_BUFF,available);
        System.out.println("String_Node_Str" + amount);
        if (amount != 0)         c=_bis.read(buf,0,amount);
 else {
          c=_bis.read();
          System.out.println("String_Node_Str" + c);
          if (c != -1) {
            buf[0]=(byte)c;
            c=1;
          }
        }
        System.out.println("String_Node_Str" + c);
        if (c == -1)         break;
        bos.write(buf,0,c);
        _amountRead+=c;
        System.out.println("String_Node_Str" + _amountRead);
        count++;
      }
      System.out.println("String_Node_Str" + _amountRead);
      System.out.println("String_Node_Str" + _sizeOfFile);
    }
  }
 catch (  Exception e) {
    _callback.error(ActivityCallback.ERROR_8);
    System.out.println("String_Node_Str" + e + "String_Node_Str");
  }
}

Fixed version (ground truth):
public void doSchmownload(){
  System.out.println("String_Node_Str");
  readHeader();
  try {
    if (_sizeOfFile != -1) {
      SettingsManager set=SettingsManager.instance();
      _downloadDir=set.getSaveDirectory();
      String pathname=_downloadDir + _filename;
      System.out.println("String_Node_Str" + pathname);
      File myFile=new File(pathname);
      FileOutputStream fos=new FileOutputStream(myFile);
      BufferedOutputStream bos=new BufferedOutputStream(fos);
      int count=0;
      int c=-1;
      byte[] buf=new byte[MAX_BUFF];
      while (true) {
        int available=_bis.available();
        System.out.println("String_Node_Str" + available);
        int amount=Math.min(MAX_BUFF,available);
        System.out.println("String_Node_Str" + amount);
        if (amount != 0)         c=_bis.read(buf,0,amount);
 else {
          c=_bis.read();
          System.out.println("String_Node_Str" + c);
          if (c != -1) {
            buf[0]=(byte)c;
            c=1;
          }
        }
        System.out.println("String_Node_Str" + c);
        if (c == -1)         break;
        bos.write(buf,0,c);
        _amountRead++;
        System.out.println("String_Node_Str" + _amountRead);
        count++;
      }
      System.out.println("String_Node_Str" + _amountRead);
      System.out.println("String_Node_Str" + _sizeOfFile);
    }
  }
 catch (  Exception e) {
    _callback.error(ActivityCallback.ERROR_8);
    System.out.println("String_Node_Str" + e + "String_Node_Str");
  }
}
Program: 5125
Project: 5125
Buggy source:
public void doUpload(){
  writeHeader();
  int c=-1;
  int available=0;
  while (true) {
    try {
      c=_fis.read();
    }
 catch (    IOException e) {
      uploadError("String_Node_Str");
      e.printStackTrace();
    }
    if (c == -1)     break;
    try {
      if (_ostream == null)       System.out.println("String_Node_Str");
      _ostream.write(c);
    }
 catch (    IOException e) {
      uploadError("String_Node_Str");
      e.printStackTrace();
    }
    _amountRead+=c;
  }
  try {
    _out.close();
  }
 catch (  IOException e) {
    uploadError("String_Node_Str");
  }
}

Fixed version (ground truth):
public void doUpload(){
  writeHeader();
  int c=-1;
  int available=0;
  while (true) {
    try {
      c=_fis.read();
    }
 catch (    IOException e) {
      uploadError("String_Node_Str");
      e.printStackTrace();
    }
    if (c == -1)     break;
    try {
      if (_ostream == null)       System.out.println("String_Node_Str");
      _ostream.write(c);
    }
 catch (    IOException e) {
      uploadError("String_Node_Str");
      e.printStackTrace();
    }
    _amountRead++;
  }
  try {
    _out.close();
  }
 catch (  IOException e) {
    uploadError("String_Node_Str");
  }
}
Program: 5126
Project: 5126
Buggy source:
public void doDownload(){
  readHeader();
  try {
    if (_sizeOfFile != -1) {
      SettingsManager set=SettingsManager.instance();
      _downloadDir=set.getSaveDirectory();
      String pathname=_downloadDir + _filename;
      System.out.println("String_Node_Str" + pathname);
      int c=-1;
      _bis=new BufferedInputStream(_istream);
      FileOutputStream fos=new FileOutputStream(pathname);
      byte[] buf=new byte[1024];
      while (true) {
        c=_istream.read(buf);
        if (c == -1)         break;
        fos.write(buf,0,c);
        _amountRead+=c;
      }
      fos.close();
      System.out.println("String_Node_Str" + _sizeOfFile);
    }
  }
 catch (  Exception e) {
    _callback.error(ActivityCallback.ERROR_8);
    System.out.println("String_Node_Str" + e + "String_Node_Str");
  }
}

Fixed version (ground truth):
public void doDownload(){
  readHeader();
  try {
    if (_sizeOfFile != -1) {
      SettingsManager set=SettingsManager.instance();
      _downloadDir=set.getSaveDirectory();
      String pathname=_downloadDir + "String_Node_Str" + _filename;
      System.out.println("String_Node_Str" + pathname);
      int c=-1;
      _bis=new BufferedInputStream(_istream);
      FileOutputStream fos=new FileOutputStream(pathname);
      byte[] buf=new byte[1024];
      while (true) {
        c=_istream.read(buf);
        if (c == -1)         break;
        fos.write(buf,0,c);
        _amountRead+=c;
      }
      fos.close();
      System.out.println("String_Node_Str" + _sizeOfFile);
    }
  }
 catch (  Exception e) {
    _callback.error(ActivityCallback.ERROR_8);
    System.out.println("String_Node_Str" + e + "String_Node_Str");
  }
}
Program: 5127
Project: 5127
Buggy source:
public void doSchmownload(){
  System.out.println("String_Node_Str");
  readHeader();
  try {
    if (_sizeOfFile != -1) {
      SettingsManager set=SettingsManager.instance();
      _downloadDir=set.getSaveDirectory();
      String pathname=_downloadDir + _filename;
      System.out.println("String_Node_Str" + pathname);
      File myFile=new File(pathname);
      FileOutputStream fos=new FileOutputStream(myFile);
      BufferedOutputStream bos=new BufferedOutputStream(fos);
      int count=0;
      int c=-1;
      byte[] buf=new byte[MAX_BUFF];
      while (true) {
        int available=_bis.available();
        System.out.println("String_Node_Str" + available);
        int amount=Math.min(MAX_BUFF,available);
        System.out.println("String_Node_Str" + amount);
        if (amount != 0)         c=_bis.read(buf,0,amount);
 else {
          c=_bis.read();
          System.out.println("String_Node_Str" + c);
          if (c != -1) {
            buf[0]=(byte)c;
            c=1;
          }
        }
        System.out.println("String_Node_Str" + c);
        if (c == -1)         break;
        bos.write(buf,0,c);
        _amountRead+=c;
        System.out.println("String_Node_Str" + _amountRead);
        count++;
      }
      System.out.println("String_Node_Str" + _amountRead);
      System.out.println("String_Node_Str" + _sizeOfFile);
    }
  }
 catch (  Exception e) {
    _callback.error(ActivityCallback.ERROR_8);
    System.out.println("String_Node_Str" + e + "String_Node_Str");
  }
}

Fixed version (ground truth):
public void doSchmownload(){
  System.out.println("String_Node_Str");
  readHeader();
  try {
    if (_sizeOfFile != -1) {
      SettingsManager set=SettingsManager.instance();
      _downloadDir=set.getSaveDirectory();
      String pathname=_downloadDir + _filename;
      System.out.println("String_Node_Str" + pathname);
      File myFile=new File(pathname);
      FileOutputStream fos=new FileOutputStream(myFile);
      BufferedOutputStream bos=new BufferedOutputStream(fos);
      int count=0;
      int c=-1;
      byte[] buf=new byte[MAX_BUFF];
      while (true) {
        int available=_bis.available();
        System.out.println("String_Node_Str" + available);
        int amount=Math.min(MAX_BUFF,available);
        System.out.println("String_Node_Str" + amount);
        if (amount != 0)         c=_bis.read(buf,0,amount);
 else {
          c=_bis.read();
          System.out.println("String_Node_Str" + c);
          if (c != -1) {
            buf[0]=(byte)c;
            c=1;
          }
        }
        System.out.println("String_Node_Str" + c);
        if (c == -1)         break;
        bos.write(buf,0,c);
        _amountRead++;
        System.out.println("String_Node_Str" + _amountRead);
        count++;
      }
      System.out.println("String_Node_Str" + _amountRead);
      System.out.println("String_Node_Str" + _sizeOfFile);
    }
  }
 catch (  Exception e) {
    _callback.error(ActivityCallback.ERROR_8);
    System.out.println("String_Node_Str" + e + "String_Node_Str");
  }
}
Program: 5128
Project: 5128
Buggy source:
public void doUpload(){
  writeHeader();
  int c=-1;
  int available=0;
  while (true) {
    try {
      c=_fis.read();
    }
 catch (    IOException e) {
      uploadError("String_Node_Str");
      e.printStackTrace();
    }
    if (c == -1)     break;
    try {
      if (_ostream == null)       System.out.println("String_Node_Str");
      _ostream.write(c);
    }
 catch (    IOException e) {
      uploadError("String_Node_Str");
      e.printStackTrace();
    }
    _amountRead+=c;
  }
  try {
    _out.close();
  }
 catch (  IOException e) {
    uploadError("String_Node_Str");
  }
}

Fixed version (ground truth):
public void doUpload(){
  writeHeader();
  int c=-1;
  int available=0;
  while (true) {
    try {
      c=_fis.read();
    }
 catch (    IOException e) {
      uploadError("String_Node_Str");
      e.printStackTrace();
    }
    if (c == -1)     break;
    try {
      if (_ostream == null)       System.out.println("String_Node_Str");
      _ostream.write(c);
    }
 catch (    IOException e) {
      uploadError("String_Node_Str");
      e.printStackTrace();
    }
    _amountRead++;
  }
  try {
    _out.close();
  }
 catch (  IOException e) {
    uploadError("String_Node_Str");
  }
}
Program: 5129
Project: 5129
Buggy source:
public static String[] stringSplit(String s,char delimeter){
  s=s.trim();
  int n=s.length();
  if (n == 0)   return new String[0];
  Vector buf=new Vector();
  for (int i=0; i < n; ) {
    if (s.charAt(i) == delimeter)     i++;
    int j=s.indexOf(delimeter,i + 1);
    if (j == -1)     j=n;
    buf.add(s.substring(i,j));
    for (i=j + 1; j < n; ) {
      if (s.charAt(i) != ' ')       break;
      i++;
    }
  }
  String[] ret=new String[buf.size()];
  for (int i=0; i < ret.length; i++)   ret[i]=(String)buf.get(i);
  return ret;
}

Fixed version (ground truth):
public static String[] stringSplit(String s,char delimeter){
  s=s.trim();
  int n=s.length();
  if (n == 0)   return new String[0];
  Vector buf=new Vector();
  for (int i=0; i < n; ) {
    if (s.charAt(i) == delimeter)     i++;
    int j=s.indexOf(delimeter,i + 1);
    if (j == -1)     j=n;
    buf.add(s.substring(i,j));
    for (i=j + 1; j < n - 1; ) {
      if (s.charAt(i) != ' ')       break;
      i++;
    }
  }
  String[] ret=new String[buf.size()];
  for (int i=0; i < ret.length; i++)   ret[i]=(String)buf.get(i);
  return ret;
}
Program: 5130
Project: 5130
Buggy source:
/** 
 * Note: the minimum speed can be represented as a 4-byte unsigned  number, but Java ints are signed.  Hence we must use a long.  The value returned is always smaller than 2^32.
 */
public long getMinSpeed(){
  int speed=ByteOrder.leb2int(payload,0);
  long ret=ByteOrder.ubytes2long(speed);
  Assert.that(ret >= 0,"String_Node_Str");
  return ret;
}

Fixed version (ground truth):
/** 
 * Note: the minimum speed can be represented as a 4-byte unsigned  number, but Java ints are signed.  Hence we must use a long.  The value returned is always smaller than 2^32.
 */
public int getMinSpeed(){
  short speed=ByteOrder.leb2short(payload,0);
  int ret=ByteOrder.ubytes2int(speed);
  Assert.that(ret >= 0,"String_Node_Str");
  return ret;
}
Program: 5131
Project: 5131
Buggy source:
/** 
 * See specification of Message.read. Note that this is non-blocking, but there is no hard guarantee on the maximum block time.  
 */
public Message receive() throws IOException, BadPacketException {
  Message m=Message.read(sock.getInputStream());
  received++;
  return m;
}

Fixed version (ground truth):
/** 
 * See specification of Message.read. Note that this is non-blocking, but there is no hard guarantee on the maximum block time.  This is thread-safe.
 */
public Message receive() throws IOException, BadPacketException {
  InputStream in=sock.getInputStream();
synchronized (in) {
    Message m=Message.read(in);
    received++;
    if (m != null)     System.out.println("String_Node_Str" + m.toString() + "String_Node_Str"+ sock.toString());
    return m;
  }
}
Program: 5132
Project: 5132
Buggy source:
/** 
 * @modifies network, modifies
 * @effects Throws IOException if handshake failed.  Otherwiseadds this manager
 * @param manager the manager managing me and my "sibling" connections
 * @param sock the socket used for communication
 * @param incoming true if this is an incoming connection.False otherwise.
 * @exception IOException if the handshake failed
 */
public Connection(ConnectionManager manager,Socket sock,boolean incoming) throws IOException {
  this.manager=manager;
  this.sock=sock;
  this.incoming=incoming;
  this.routeTable=manager.routeTable;
  final String CONNECT="String_Node_Str";
  final String OK="String_Node_Str";
  if (incoming) {
    expectString(CONNECT);
    sendString(OK);
  }
 else {
    sendString(CONNECT);
    expectString(OK);
    Message m=new PingRequest(Const.TTL);
    send(m);
    routeTable.put(m.getGUID(),this);
  }
  manager.add(this);
  System.out.println("String_Node_Str" + (incoming ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ sock.toString());
}

Fixed version (ground truth):
/** 
 * Creates an outgoing or incoming connection around an existing socket.
 * @modifies network, manager
 * @effects wraps a connection around sock and does the Gnutella handshake.Throws IOException if the connection couldn't be established. If manager is non-null, also registers this with manager and sends an initial PingRequest if this is outgoing..
 * @param manager the manager managing me and my "sibling" connections, or nullif the run() method will not be called.
 * @param sock the socket used for communication
 * @param incoming true if this is an incoming connection.False otherwise.
 * @exception IOException if the handshake failed
 */
public Connection(ConnectionManager manager,Socket sock,boolean incoming) throws IOException {
  this.manager=manager;
  this.sock=sock;
  this.incoming=incoming;
  if (manager != null)   this.routeTable=manager.routeTable;
  final String CONNECT="String_Node_Str";
  final String OK="String_Node_Str";
  if (incoming) {
    expectString(CONNECT);
    sendString(OK);
  }
 else {
    sendString(CONNECT);
    expectString(OK);
    if (manager != null) {
      Message m=new PingRequest(Const.TTL);
      send(m);
      routeTable.put(m.getGUID(),this);
    }
  }
  if (manager != null)   manager.add(this);
  System.out.println("String_Node_Str" + (incoming ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ sock.toString());
}
Program: 5134
Project: 5134
Buggy source:
/** 
 * @modifies : the network underlying this
 * @effects : send m on the network.  Throws IOException if problems arise.
 */
public synchronized void send(Message m) throws IOException {
  OutputStream out=sock.getOutputStream();
  m.write(out);
  out.flush();
  sent++;
}

Fixed version (ground truth):
/** 
 * @modifies the network underlying this
 * @effects send m on the network.  Throws IOException if problemsarise.  This is thread-safe.
 */
public void send(Message m) throws IOException {
  OutputStream out=sock.getOutputStream();
synchronized (out) {
    m.write(out);
    out.flush();
    sent++;
  }
  System.out.println("String_Node_Str" + m.toString() + "String_Node_Str"+ sock.toString());
}
Program: 5135
Project: 5135
Buggy source:
/** 
 * @modifies this
 * @effects adds any hosts listed in m to this
 */
public void spy(Message m){
  String ip=null;
  int port=6346;
  if (m instanceof PingReply) {
    ip=((PingReply)m).getIP();
    port=port;
  }
 else {
    return;
  }
synchronized (candidates) {
    candidates.add(new Endpoint(ip,port));
  }
}

Fixed version (ground truth):
/** 
 * @modifies this
 * @effects ensures any hosts listed in m are in this
 */
public void spy(Message m){
  String ip=null;
  int port=6346;
  if (m instanceof PingReply) {
    PingReply pr=(PingReply)m;
    ip=pr.getIP();
    port=pr.getPort();
  }
 else {
    return;
  }
synchronized (candidates) {
    Endpoint e=new Endpoint(ip,port);
    if (!elected.contains(e)) {
      candidates.add(e);
    }
  }
}
Program: 5136
Project: 5136
Buggy source:
/** 
 * Little-endian bytes to int
 * @requires x.length-offset>=4
 * @effects returns the value of x[offset..offset+4] as an int, assuming x is interpreted as a signed little endian number (i.e.,  x[offset] is LSB) If you want to interpret it as an unsigned number, call ubytes2int on the result.
 */
public static int leb2int(byte[] x,int offset){
  int x0=x[offset];
  int x1=x[offset + 1] << 8;
  int x2=x[offset + 2] << 16;
  int x3=x[offset + 3] << 24;
  return x3 | x2 | x1| x0;
}

Fixed version (ground truth):
/** 
 * Little-endian bytes to int
 * @requires x.length-offset>=4
 * @effects returns the value of x[offset..offset+4] as an int, assuming x is interpreted as a signed little endian number (i.e.,  x[offset] is LSB) If you want to interpret it as an unsigned number, call ubytes2int on the result.
 */
public static int leb2int(byte[] x,int offset){
  int x0=x[offset] & 0x000000FF;
  int x1=(x[offset + 1] << 8) & 0x0000FF00;
  int x2=(x[offset + 2] << 16) & 0x00FF0000;
  int x3=(x[offset + 3] << 24);
  return x3 | x2 | x1| x0;
}
Program: 5137
Project: 5137
Buggy source:
/** 
 * Little-endian bytes to short
 * @requires x.length-offset>=2
 * @effects returns the value of x[offset..offset+2] as a short, assuming x is interpreted as a signed little endian number (i.e.,  x[offset] is LSB).  If you want to interpret it as an unsigned number, call ubytes2int on the result.
 */
public static short leb2short(byte[] x,int offset){
  short x0=(short)x[offset];
  short x1=(short)(x[offset + 1] << 8);
  return (short)(x1 | x0);
}

Fixed version (ground truth):
/** 
 * Little-endian bytes to short
 * @requires x.length-offset>=2
 * @effects returns the value of x[offset..offset+2] as a short, assuming x is interpreted as a signed little endian number (i.e.,  x[offset] is LSB).  If you want to interpret it as an unsigned number, call ubytes2int on the result.
 */
public static short leb2short(byte[] x,int offset){
  int x0=(x[offset]) & 0x000000FF;
  int x1=(x[offset + 1] << 8);
  return (short)(x1 | x0);
}
Program: 5138
Project: 5138
Buggy source:
/** 
 * Little-endian bytes to int
 * @requires x.length-offset>=4
 * @effects returns the value of x[offset..offset+4] as an int, assuming x is interpreted in a little endian number (i.e.,  x[offset] is LSB) 
 */
public static int leb2int(byte[] x,int offset){
  int x0=x[offset];
  int x1=x[offset + 1] << 8;
  int x2=x[offset + 2] << 16;
  int x3=x[offset + 3] << 24;
  return x0 + x1 + x2+ x3;
}

Fixed version (ground truth):
/** 
 * Little-endian bytes to int
 * @requires x.length-offset>=4
 * @effects returns the value of x[offset..offset+4] as an int, assuming x is interpreted as a signed little endian number (i.e.,  x[offset] is LSB) If you want to interpret it as an unsigned number, call ubytes2int on the result.
 */
public static int leb2int(byte[] x,int offset){
  int x0=x[offset];
  int x1=x[offset + 1] << 8;
  int x2=x[offset + 2] << 16;
  int x3=x[offset + 3] << 24;
  return x3 | x2 | x1| x0;
}
Program: 5139
Project: 5139
Buggy source:
/** 
 * Little-endian bytes to short
 * @requires x.length-offset>=2
 * @effects returns the value of x[offset..offset+2] as a short, assuming x is interpreted in a little endian number (i.e.,  x[offset] is LSB) 
 */
public static short leb2short(byte[] x,int offset){
  short x0=(short)x[offset];
  short x1=(short)(x[offset + 1] << 8);
  return (short)(x0 + x1);
}

Fixed version (ground truth):
/** 
 * Little-endian bytes to short
 * @requires x.length-offset>=2
 * @effects returns the value of x[offset..offset+2] as a short, assuming x is interpreted as a signed little endian number (i.e.,  x[offset] is LSB).  If you want to interpret it as an unsigned number, call ubytes2int on the result.
 */
public static short leb2short(byte[] x,int offset){
  short x0=(short)x[offset];
  short x1=(short)(x[offset + 1] << 8);
  return (short)(x1 | x0);
}
Program: 5140
Project: 5140
Buggy source:
/** 
 * Interprets the value of b as an unsigned byte, and returns  it as integer.  For example, ubyte2int(0xFF)==255, not -1.
 */
public static int ubyte2int(byte b){
  return ((int)b) & 0x000000FF;
}

Fixed version (ground truth):
/** 
 * Interprets the value of x as an unsigned byte, and returns  it as integer.  For example, ubyte2int(0xFF)==255, not -1.
 */
public static int ubyte2int(byte x){
  return ((int)x) & 0x000000FF;
}
Program: 5141
Project: 5141
Buggy source:
/** 
 * Returns the ip (in LITTLE-endian) format as standard dotted-decimal, e.g., 192.168.0.1 
 */
protected static String ip2string(byte[] ip){
  StringBuffer buf=new StringBuffer();
  buf.append(ByteOrder.ubyte2int(ip[3]) + "String_Node_Str");
  buf.append(ByteOrder.ubyte2int(ip[2]) + "String_Node_Str");
  buf.append(ByteOrder.ubyte2int(ip[1]) + "String_Node_Str");
  buf.append(ByteOrder.ubyte2int(ip[3]) + "String_Node_Str");
  return buf.toString();
}

Fixed version (ground truth):
/** 
 * Returns the ip (given in LITTLE-endian) format as standard dotted-decimal, e.g., 192.168.0.1 
 */
protected static String ip2string(byte[] ip){
  StringBuffer buf=new StringBuffer();
  buf.append(ByteOrder.ubyte2int(ip[3]) + "String_Node_Str");
  buf.append(ByteOrder.ubyte2int(ip[2]) + "String_Node_Str");
  buf.append(ByteOrder.ubyte2int(ip[1]) + "String_Node_Str");
  buf.append(ByteOrder.ubyte2int(ip[0]) + "String_Node_Str");
  return buf.toString();
}
Program: 5142
Project: 5142
Buggy source:
public Object invokeMethod(String controllerName,Method method,Object[] parameter){
  try {
    if (controllerName != null) {
      LOGGER.debug("String_Node_Str",method.getName(),controllerName);
      IMeasurementEnvironmentController mec=MECApplication.get().getMEController(controllerName);
      return method.invoke(mec,parameter);
    }
 else {
      LOGGER.debug("String_Node_Str",method.getName());
      return method.invoke(this,parameter);
    }
  }
 catch (  IllegalArgumentException e) {
    e.printStackTrace();
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
catch (  InvocationTargetException e) {
    e.printStackTrace();
  }
  return null;
}

Fixed version (ground truth):
public Object invokeMethod(String controllerName,Method method,Object[] parameter){
  try {
    if (controllerName != null) {
      LOGGER.debug("String_Node_Str",method.getName(),controllerName);
      IMeasurementEnvironmentController mec=MECApplication.get().getMEController(controllerName);
      return method.invoke(mec,parameter);
    }
 else {
      LOGGER.debug("String_Node_Str",method.getName());
      return method.invoke(this,parameter);
    }
  }
 catch (  IllegalArgumentException e) {
    e.printStackTrace();
    return e;
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
    return e;
  }
catch (  InvocationTargetException e) {
    e.printStackTrace();
    return e;
  }
}
Program: 5143
Project: 5143
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public Collection<ParameterValueList<?>> runExperiment(String acquirerID,ParameterCollection<ParameterValue<?>> inputPVs) throws RemoteException, ExperimentFailedException {
  Object result=call(acquirerID,inputPVs);
  while (true) {
    if (result instanceof StatusMessage) {
      StatusBroker.getManagerViaSessionID(acquirerID).newStatus((StatusMessage)result);
    }
 else {
      break;
    }
    try {
      result=getOiStream().readObject();
    }
 catch (    IOException e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
catch (    ClassNotFoundException e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
  }
  return (Collection<ParameterValueList<?>>)result;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public Collection<ParameterValueList<?>> runExperiment(String acquirerID,ParameterCollection<ParameterValue<?>> inputPVs) throws RemoteException, ExperimentFailedException {
  Object result=call(acquirerID,inputPVs);
  while (true) {
    if (result instanceof StatusMessage) {
      StatusBroker.getManagerViaSessionID(acquirerID).newStatus((StatusMessage)result);
    }
 else {
      break;
    }
    try {
      result=getOiStream().readObject();
    }
 catch (    IOException e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
catch (    ClassNotFoundException e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
  }
  if (result instanceof InvocationTargetException) {
    InvocationTargetException exc=(InvocationTargetException)result;
    throw new RuntimeException(exc.getCause());
  }
 else   if (result instanceof Exception) {
    throw new RuntimeException((Exception)result);
  }
  return (Collection<ParameterValueList<?>>)result;
}
Program: 5144
Project: 5144
Buggy source:
/** 
 * Reads the file specified by the given   {@link pathToFile} parameter andreturns a complete  {@link ScenarioDefinition} instance.
 * @param pathToFile absolute path to the XML file
 * @return Returns a {@link ScenarioDefinition} instance.
 */
public ScenarioDefinition read(String pathToFile){
  LOGGER.debug("String_Node_Str",pathToFile);
  XScenarioDefinition sd=null;
  try {
    JAXBContext jc=JAXBContext.newInstance(Configuration.getSessionUnrelatedSingleton().getPropertyAsStr(IConfiguration.CONF_SCENARIO_DEFINITION_PACKAGE));
    Unmarshaller u=jc.createUnmarshaller();
    sd=((JAXBElement<XScenarioDefinition>)u.unmarshal(new FileInputStream(pathToFile))).getValue();
  }
 catch (  FileNotFoundException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
catch (  JAXBException e) {
    throw new RuntimeException(e);
  }
  return convert(sd);
}

Fixed version (ground truth):
/** 
 * Reads the file specified by the given   {@link pathToFile} parameter andreturns a complete  {@link ScenarioDefinition} instance.
 * @param pathToFile absolute path to the XML file
 * @return Returns a {@link ScenarioDefinition} instance.
 */
public ScenarioDefinition read(String pathToFile){
  LOGGER.debug("String_Node_Str",pathToFile);
  XScenarioDefinition sd=null;
  try {
    JAXBContext jc=JAXBContext.newInstance(Configuration.getSessionUnrelatedSingleton().getPropertyAsStr(IConfiguration.CONF_SCENARIO_DEFINITION_PACKAGE));
    Unmarshaller u=jc.createUnmarshaller();
    sd=((JAXBElement<XScenarioDefinition>)u.unmarshal(new FileInputStream(pathToFile))).getValue();
  }
 catch (  FileNotFoundException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
catch (  JAXBException e) {
    throw new RuntimeException(e);
  }
  ScenarioDefinition scenarioDefinition=convertScenarioDefinition(sd);
  scenarioDefinition.setMeasurementEnvironmentDefinition(meDefinition);
  return scenarioDefinition;
}
Program: 5145
Project: 5145
Buggy source:
private ExperimentTerminationCondition convertTerminationCondition(XExtensibleElement xTerminationCondition){
  Map<String,String> config=new HashMap<String,String>();
  for (  XConfigurationNode xConfigNode : xTerminationCondition.getConfig()) {
    config.put(xConfigNode.getKey(),xConfigNode.getValue());
  }
  return EntityFactory.createTerminationCondition(xTerminationCondition.getName(),config);
}

Fixed version (ground truth):
/** 
 * Converts the xml representation of a termination condition to a  {@link ExperimentTerminationCondition} object.
 * @param xTerminationCondition xml representation of a termination condition
 * @return {@link ExperimentTerminationCondition} object
 */
private ExperimentTerminationCondition convertTerminationCondition(XExtensibleElement xTerminationCondition){
  Map<String,String> config=new HashMap<String,String>();
  for (  XConfigurationNode xConfigNode : xTerminationCondition.getConfig()) {
    config.put(xConfigNode.getKey(),xConfigNode.getValue());
  }
  return EntityFactory.createTerminationCondition(xTerminationCondition.getName(),config);
}
Program: 5146
Project: 5146
Buggy source:
private ExplorationStrategy convertExplorationStrategy(XExplorationStrategy xExplorationStrategy){
  Map<String,String> config=new HashMap<String,String>();
  for (  XConfigurationNode xConfigNode : xExplorationStrategy.getConfig()) {
    config.put(xConfigNode.getKey(),xConfigNode.getValue());
  }
  ExplorationStrategy explStrategy=EntityFactory.createExplorationStrategy(xExplorationStrategy.getName(),config);
  for (  XAnalysisConfiguration xAnalysisConfig : xExplorationStrategy.getAnalysisConfig()) {
    explStrategy.getAnalysisConfigurations().add(convert(xAnalysisConfig));
  }
  return explStrategy;
}

Fixed version (ground truth):
/** 
 * Converts the xml representation of an exploration strategy to a  {@link ExplorationStrategy} object.
 * @param xExplorationStrategy xml representation of an exploration strategy
 * @return {@link ExplorationStrategy} object
 */
private ExplorationStrategy convertExplorationStrategy(XExplorationStrategy xExplorationStrategy){
  Map<String,String> config=new HashMap<String,String>();
  for (  XConfigurationNode xConfigNode : xExplorationStrategy.getConfig()) {
    config.put(xConfigNode.getKey(),xConfigNode.getValue());
  }
  ExplorationStrategy explStrategy=EntityFactory.createExplorationStrategy(xExplorationStrategy.getName(),config);
  for (  XAnalysisConfiguration xAnalysisConfig : xExplorationStrategy.getAnalysisConfig()) {
    explStrategy.getAnalysisConfigurations().add(convertAnalysisConfiguration(xAnalysisConfig));
  }
  return explStrategy;
}
Program: 5147
Project: 5147
Buggy source:
@Override public void runExperimentSeries(ExperimentSeriesRun expSeriesRun,List<IParameterVariation> parameterVariations){
  if (parameterVariations == null || parameterVariations.isEmpty()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  strategyConfig=expSeriesRun.getExperimentSeries().getExperimentSeriesDefinition().getExplorationStrategy();
  if (strategyConfig.getName().equalsIgnoreCase(ScreeningConfiguration.FULL_FACTORIAL)) {
    adapter=new FullFactorialAdapter();
  }
 else   if (strategyConfig.getName().equalsIgnoreCase(ScreeningConfiguration.FRACTIONAL_FACTORIAL)) {
    adapter=new FullFactorialAdapter();
  }
 else   if (strategyConfig.getName().equalsIgnoreCase(ScreeningConfiguration.PLACKETT_BURMAN)) {
    adapter=new FullFactorialAdapter();
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + strategyConfig.getName());
  }
  adapter.setParameterVariations(parameterVariations);
  adapter.setExplorationConf(strategyConfig);
  adapter.generateDesign();
  numberOfMeasurements=0;
  executeExperimentSeries(expSeriesRun);
}

Fixed version (ground truth):
@Override public void runExperimentSeries(ExperimentSeriesRun expSeriesRun,List<IParameterVariation> parameterVariations){
  if (parameterVariations == null || parameterVariations.isEmpty()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  strategyConfig=expSeriesRun.getExperimentSeries().getExperimentSeriesDefinition().getExplorationStrategy();
  if (strategyConfig.getName().equalsIgnoreCase(ScreeningConfiguration.FULL_FACTORIAL)) {
    adapter=new FullFactorialAdapter();
  }
 else   if (strategyConfig.getName().equalsIgnoreCase(ScreeningConfiguration.FRACTIONAL_FACTORIAL)) {
    adapter=new FractionalFactorialAdapter();
  }
 else   if (strategyConfig.getName().equalsIgnoreCase(ScreeningConfiguration.PLACKETT_BURMAN)) {
    adapter=new PlackettBurmanAdapter();
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + strategyConfig.getName());
  }
  adapter.setParameterVariations(parameterVariations);
  adapter.setExplorationConf(strategyConfig);
  adapter.generateDesign();
  numberOfMeasurements=0;
  executeExperimentSeries(expSeriesRun);
}
Program: 5148
Project: 5148
Buggy source:
@Override public IExplorationStrategy createExtensionArtifact(){
  return new BreakdownExplorationController(this);
}

Fixed version (ground truth):
@Override public IExplorationStrategy createExtensionArtifact(){
  return new ScreeningDesignExploration(this);
}
Program: 5149
Project: 5149
Buggy source:
public String getType(){
  return type;
}

Fixed version (ground truth):
public String getType(){
  return type.toUpperCase();
}
Program: 5150
Project: 5150
Buggy source:
@Override public int hashCode(){
  final int prime=31;
  int result=1;
  result=prime * result + ((getFullName() == null) ? 0 : getFullName().hashCode());
  result=prime * result + ((role == null) ? 0 : role.hashCode());
  result=prime * result + ((type == null) ? 0 : type.hashCode());
  return result;
}

Fixed version (ground truth):
@Override public int hashCode(){
  final int prime=31;
  int result=1;
  result=prime * result + ((getFullName() == null) ? 0 : getFullName().hashCode());
  result=prime * result + ((getRole() == null) ? 0 : getRole().hashCode());
  result=prime * result + ((getType() == null) ? 0 : getType().hashCode());
  return result;
}
Program: 5151
Project: 5151
Buggy source:
public static ExplorationStrategy createExplorationStrategy(String name,Map<String,String> config){
  ExplorationStrategy es=new ExplorationStrategy();
  es.setName(name);
  es.getConfiguration().putAll(config);
  return es;
}

Fixed version (ground truth):
public static ExplorationStrategy createExplorationStrategy(String name,Map<String,String> config){
  ExplorationStrategy es=new ExplorationStrategy();
  es.setName(name);
  if (config != null) {
    es.getConfiguration().putAll(config);
  }
  return es;
}
Program: 5152
Project: 5152
Buggy source:
/** 
 * Configures the logging system with the provided logger configuration file.
 */
private void configureLogger(){
  LoggerContext lc=(LoggerContext)LoggerFactory.getILoggerFactory();
  String fileName=getPropertyAsStr(CONF_LOGGER_CONFIG_FILE_NAME);
  if (fileName != null) {
    try {
      logger.debug("String_Node_Str",fileName);
      JoranConfigurator configurator=new JoranConfigurator();
      configurator.setContext(lc);
      lc.reset();
      configurator.doConfigure(findConfigFileAsInputStream(ClassLoader.getSystemClassLoader(),null,fileName));
    }
 catch (    JoranException je) {
      logger.warn("String_Node_Str",je.getMessage());
    }
catch (    FileNotFoundException e) {
      logger.warn("String_Node_Str",fileName);
    }
    logger.debug("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Configures the logging system with the provided logger configuration file.
 */
private void configureLogger(){
  String fileName=getPropertyAsStr(CONF_LOGGER_CONFIG_FILE_NAME);
  if (fileName != null) {
    LoggerContext lc=(LoggerContext)LoggerFactory.getILoggerFactory();
    try {
      logger.debug("String_Node_Str",fileName);
      JoranConfigurator configurator=new JoranConfigurator();
      configurator.setContext(lc);
      lc.reset();
      configurator.doConfigure(findConfigFileAsInputStream(ClassLoader.getSystemClassLoader(),null,fileName));
    }
 catch (    JoranException je) {
      logger.warn("String_Node_Str",je.getMessage());
    }
catch (    FileNotFoundException e) {
      logger.warn("String_Node_Str",fileName);
    }
    logger.debug("String_Node_Str");
  }
}
Program: 5154
Project: 5154
Buggy source:
/** 
 * Returns the size of observation values if they are consistent (i.e., they are either 1 or the same size). Otherwise, returns -1.
 * @param collection
 * @return -1, if data sizes are inconsistent, otherwise the size of observation parameter value lists.
 */
private int sameSizeOfAllVPLs(Collection<ParameterValueList<?>> collection){
  if (collection.size() <= 1) {
    return 0;
  }
  boolean first=true;
  int relSize=0;
  for (  ParameterValueList pvl : collection) {
    if (first) {
      first=false;
      relSize=pvl.getValues().size();
    }
 else {
      if (pvl.getValues().size() != 1 && pvl.getValues().size() != relSize) {
        return -1;
      }
    }
  }
  return relSize;
}

Fixed version (ground truth):
/** 
 * Returns the size of observation values if they are consistent (i.e., they are either 1 or the same size). Otherwise, returns -1.
 * @param collection
 * @return -1, if data sizes are inconsistent, otherwise the size of observation parameter value lists.
 */
private int sameSizeOfAllVPLs(List<ParameterValueList<?>> collection){
  if (collection.size() == 1) {
    return collection.get(0).getValues().size();
  }
  boolean first=true;
  int relSize=0;
  for (  ParameterValueList pvl : collection) {
    if (first) {
      first=false;
      relSize=pvl.getValues().size();
    }
 else {
      if (pvl.getValues().size() != 1 && pvl.getValues().size() != relSize) {
        return -1;
      }
    }
  }
  return relSize;
}