Program: 140835
Project: 140835
Buggy source:
/** 
 * Method run
 */
public void run(){
  try {
    active=true;
    HTTPProxyHost=System.getProperty("String_Node_Str");
    if ((HTTPProxyHost != null) && HTTPProxyHost.equals("String_Node_Str")) {
      HTTPProxyHost=null;
    }
    if (HTTPProxyHost != null) {
      String tmp=System.getProperty("String_Node_Str");
      if ((tmp != null) && tmp.equals("String_Node_Str")) {
        tmp=null;
      }
      if (tmp == null) {
        HTTPProxyPort=80;
      }
 else {
        HTTPProxyPort=Integer.parseInt(tmp);
      }
    }
    if (inSocket != null) {
      fromHost=(inSocket.getInetAddress()).getHostName();
    }
 else {
      fromHost="String_Node_Str";
    }
    String dateformat=TCPMon.getMessage("String_Node_Str","String_Node_Str");
    DateFormat df=new SimpleDateFormat(dateformat);
    time=df.format(new Date());
    int count=listener.connections.size();
    listener.tableModel.insertRow(count + 1,new Object[]{TCPMon.getMessage("String_Node_Str","String_Node_Str"),time,fromHost,listener.hostField.getText(),"String_Node_Str"});
    listener.connections.add(this);
    inputText=new JTextArea(null,null,20,80);
    inputScroll=new JScrollPane(inputText);
    outputText=new JTextArea(null,null,20,80);
    outputScroll=new JScrollPane(outputText);
    ListSelectionModel lsm=listener.connectionTable.getSelectionModel();
    if ((count == 0) || (lsm.getLeadSelectionIndex() == 0)) {
      listener.outPane.setVisible(false);
      int divLoc=listener.outPane.getDividerLocation();
      listener.setLeft(inputScroll);
      listener.setRight(outputScroll);
      listener.removeButton.setEnabled(false);
      listener.removeAllButton.setEnabled(true);
      listener.saveButton.setEnabled(true);
      listener.resendButton.setEnabled(true);
      listener.outPane.setDividerLocation(divLoc);
      listener.outPane.setVisible(true);
    }
    String targetHost=listener.hostField.getText();
    int targetPort=Integer.parseInt(listener.tPortField.getText());
    int listenPort=Integer.parseInt(listener.portField.getText());
    InputStream tmpIn1=inputStream;
    OutputStream tmpOut1=null;
    InputStream tmpIn2=null;
    OutputStream tmpOut2=null;
    if (tmpIn1 == null) {
      tmpIn1=inSocket.getInputStream();
    }
    if (inSocket != null) {
      tmpOut1=inSocket.getOutputStream();
    }
    String bufferedData=null;
    StringBuffer buf=null;
    int index=listener.connections.indexOf(this);
    if (listener.isProxyBox.isSelected() || (HTTPProxyHost != null)) {
      byte[] b=new byte[1];
      buf=new StringBuffer();
      String s;
      for (; ; ) {
        int len;
        len=tmpIn1.read(b,0,1);
        if (len == -1) {
          break;
        }
        s=new String(b);
        buf.append(s);
        if (b[0] != '\n') {
          continue;
        }
        break;
      }
      bufferedData=buf.toString();
      inputText.append(bufferedData);
      if (bufferedData.startsWith("String_Node_Str") || bufferedData.startsWith("String_Node_Str") || bufferedData.startsWith("String_Node_Str")|| bufferedData.startsWith("String_Node_Str")) {
        int start, end;
        URL url;
        start=bufferedData.indexOf(' ') + 1;
        while (bufferedData.charAt(start) == ' ') {
          start++;
        }
        end=bufferedData.indexOf(' ',start);
        String urlString=bufferedData.substring(start,end);
        if (urlString.charAt(0) == '/') {
          urlString=urlString.substring(1);
        }
        if (listener.isProxyBox.isSelected()) {
          url=new URL(urlString);
          targetHost=url.getHost();
          targetPort=url.getPort();
          if (targetPort == -1) {
            targetPort=80;
          }
          listener.tableModel.setValueAt(targetHost,index + 1,TCPMon.OUTHOST_COLUMN);
          bufferedData=bufferedData.substring(0,start) + url.getFile() + bufferedData.substring(end);
        }
 else {
          url=new URL("String_Node_Str" + targetHost + "String_Node_Str"+ targetPort+ "String_Node_Str"+ urlString);
          listener.tableModel.setValueAt(targetHost,index + 1,TCPMon.OUTHOST_COLUMN);
          bufferedData=bufferedData.substring(0,start) + url.toExternalForm() + bufferedData.substring(end);
          targetHost=HTTPProxyHost;
          targetPort=HTTPProxyPort;
        }
      }
    }
 else {
      byte[] b1=new byte[1];
      buf=new StringBuffer();
      String s1;
      String lastLine=null;
      for (; ; ) {
        int len;
        len=tmpIn1.read(b1,0,1);
        if (len == -1) {
          break;
        }
        s1=new String(b1);
        buf.append(s1);
        if (b1[0] != '\n') {
          continue;
        }
        String line=buf.toString();
        buf.setLength(0);
        if (line.startsWith("String_Node_Str")) {
          String newHost="String_Node_Str" + targetHost + "String_Node_Str"+ listenPort+ "String_Node_Str";
          bufferedData=bufferedData.concat(newHost);
          break;
        }
        if (bufferedData == null) {
          bufferedData=line;
        }
 else {
          bufferedData=bufferedData.concat(line);
        }
        if (line.equals("String_Node_Str")) {
          break;
        }
        if ("String_Node_Str".equals(lastLine) && line.equals("String_Node_Str")) {
          break;
        }
        lastLine=line;
      }
      if (bufferedData != null) {
        inputText.append(bufferedData);
        int idx=(bufferedData.length() < 50) ? bufferedData.length() : 50;
        s1=bufferedData.substring(0,idx);
        int i=s1.indexOf('\n');
        if (i > 0) {
          s1=s1.substring(0,i - 1);
        }
        s1=s1 + "String_Node_Str" + "String_Node_Str";
        s1=s1.substring(0,51);
        listener.tableModel.setValueAt(s1,index + 1,TCPMon.REQ_COLUMN);
      }
    }
    if (targetPort == -1) {
      targetPort=80;
    }
    outSocket=new Socket(targetHost,targetPort);
    tmpIn2=outSocket.getInputStream();
    tmpOut2=outSocket.getOutputStream();
    if (bufferedData != null) {
      byte[] b=bufferedData.getBytes();
      tmpOut2.write(b);
      slowLink.pump(b.length);
    }
    boolean format=listener.xmlFormatBox.isSelected();
    rr1=new SocketRR(this,inSocket,tmpIn1,outSocket,tmpOut2,inputText,format,listener.tableModel,index + 1,"String_Node_Str",slowLink);
    SlowLinkSimulator responseLink=new SlowLinkSimulator(slowLink);
    rr2=new SocketRR(this,outSocket,tmpIn2,inSocket,tmpOut1,outputText,format,null,0,"String_Node_Str",responseLink);
    while ((rr1 != null) || (rr2 != null)) {
      if (rr2 != null) {
        listener.tableModel.setValueAt(rr2.getElapsed(),1 + index,TCPMon.ELAPSED_COLUMN);
      }
      if ((null != rr1) && rr1.isDone()) {
        if ((index >= 0) && (rr2 != null)) {
          listener.tableModel.setValueAt(TCPMon.getMessage("String_Node_Str","String_Node_Str"),1 + index,TCPMon.STATE_COLUMN);
        }
        rr1=null;
      }
      if ((null != rr2) && rr2.isDone()) {
        if ((index >= 0) && (rr1 != null)) {
          listener.tableModel.setValueAt(TCPMon.getMessage("String_Node_Str","String_Node_Str"),1 + index,TCPMon.STATE_COLUMN);
        }
        rr2=null;
      }
synchronized (this) {
        this.wait(100);
      }
    }
    active=false;
    if (index >= 0) {
      listener.tableModel.setValueAt(TCPMon.getMessage("String_Node_Str","String_Node_Str"),1 + index,TCPMon.STATE_COLUMN);
    }
  }
 catch (  Exception e) {
    StringWriter st=new StringWriter();
    PrintWriter wr=new PrintWriter(st);
    int index=listener.connections.indexOf(this);
    if (index >= 0) {
      listener.tableModel.setValueAt(TCPMon.getMessage("String_Node_Str","String_Node_Str"),1 + index,TCPMon.STATE_COLUMN);
    }
    e.printStackTrace(wr);
    wr.close();
    if (outputText != null) {
      outputText.append(st.toString());
    }
 else {
      System.out.println(st.toString());
    }
    halt();
  }
}

Fixed version (ground truth):
/** 
 * Method run
 */
public void run(){
  try {
    active=true;
    HTTPProxyHost=System.getProperty("String_Node_Str");
    if ((HTTPProxyHost != null) && HTTPProxyHost.equals("String_Node_Str")) {
      HTTPProxyHost=null;
    }
    if (HTTPProxyHost != null) {
      String tmp=System.getProperty("String_Node_Str");
      if ((tmp != null) && tmp.equals("String_Node_Str")) {
        tmp=null;
      }
      if (tmp == null) {
        HTTPProxyPort=80;
      }
 else {
        HTTPProxyPort=Integer.parseInt(tmp);
      }
    }
    if (inSocket != null) {
      fromHost=(inSocket.getInetAddress()).getHostName();
    }
 else {
      fromHost="String_Node_Str";
    }
    String dateformat=TCPMon.getMessage("String_Node_Str","String_Node_Str");
    DateFormat df=new SimpleDateFormat(dateformat);
    time=df.format(new Date());
    int count=listener.connections.size();
    listener.tableModel.insertRow(count + 1,new Object[]{TCPMon.getMessage("String_Node_Str","String_Node_Str"),time,fromHost,listener.hostField.getText(),"String_Node_Str"});
    listener.connections.add(this);
    inputText=new JTextArea(null,null,20,80);
    inputScroll=new JScrollPane(inputText);
    outputText=new JTextArea(null,null,20,80);
    outputScroll=new JScrollPane(outputText);
    ListSelectionModel lsm=listener.connectionTable.getSelectionModel();
    if ((count == 0) || (lsm.getLeadSelectionIndex() == 0)) {
      listener.outPane.setVisible(false);
      int divLoc=listener.outPane.getDividerLocation();
      listener.setLeft(inputScroll);
      listener.setRight(outputScroll);
      listener.removeButton.setEnabled(false);
      listener.removeAllButton.setEnabled(true);
      listener.saveButton.setEnabled(true);
      listener.resendButton.setEnabled(true);
      listener.outPane.setDividerLocation(divLoc);
      listener.outPane.setVisible(true);
    }
    String targetHost=listener.hostField.getText();
    int targetPort=Integer.parseInt(listener.tPortField.getText());
    int listenPort=Integer.parseInt(listener.portField.getText());
    InputStream tmpIn1=inputStream;
    OutputStream tmpOut1=null;
    InputStream tmpIn2=null;
    OutputStream tmpOut2=null;
    if (tmpIn1 == null) {
      tmpIn1=inSocket.getInputStream();
    }
    if (inSocket != null) {
      tmpOut1=inSocket.getOutputStream();
    }
    String bufferedData=null;
    StringBuffer buf=null;
    int index=listener.connections.indexOf(this);
    if (listener.isProxyBox.isSelected() || (HTTPProxyHost != null)) {
      byte[] b=new byte[1];
      buf=new StringBuffer();
      String s;
      for (; ; ) {
        int len;
        len=tmpIn1.read(b,0,1);
        if (len == -1) {
          break;
        }
        s=new String(b);
        buf.append(s);
        if (b[0] != '\n') {
          continue;
        }
        break;
      }
      bufferedData=buf.toString();
      inputText.append(bufferedData);
      if (bufferedData.startsWith("String_Node_Str") || bufferedData.startsWith("String_Node_Str") || bufferedData.startsWith("String_Node_Str")|| bufferedData.startsWith("String_Node_Str")) {
        int start, end;
        URL url;
        start=bufferedData.indexOf(' ') + 1;
        while (bufferedData.charAt(start) == ' ') {
          start++;
        }
        end=bufferedData.indexOf(' ',start);
        String urlString=bufferedData.substring(start,end);
        if (urlString.charAt(0) == '/') {
          urlString=urlString.substring(1);
        }
        if (listener.isProxyBox.isSelected()) {
          url=new URL(urlString);
          targetHost=url.getHost();
          targetPort=url.getPort();
          if (targetPort == -1) {
            targetPort=80;
          }
          listener.tableModel.setValueAt(targetHost,index + 1,TCPMon.OUTHOST_COLUMN);
          bufferedData=bufferedData.substring(0,start) + url.getFile() + bufferedData.substring(end);
        }
 else {
          url=new URL("String_Node_Str" + targetHost + "String_Node_Str"+ targetPort+ "String_Node_Str"+ urlString);
          listener.tableModel.setValueAt(targetHost,index + 1,TCPMon.OUTHOST_COLUMN);
          bufferedData=bufferedData.substring(0,start) + url.toExternalForm() + bufferedData.substring(end);
          targetHost=HTTPProxyHost;
          targetPort=HTTPProxyPort;
        }
      }
    }
 else {
      byte[] b1=new byte[1];
      buf=new StringBuffer();
      String s1;
      String lastLine=null;
      for (; ; ) {
        int len;
        len=tmpIn1.read(b1,0,1);
        if (len == -1) {
          break;
        }
        s1=new String(b1);
        buf.append(s1);
        if (b1[0] != '\n') {
          continue;
        }
        String line=buf.toString();
        buf.setLength(0);
        if (line.startsWith("String_Node_Str")) {
          String newHost="String_Node_Str" + targetHost + "String_Node_Str"+ targetPort+ "String_Node_Str";
          bufferedData=bufferedData.concat(newHost);
          break;
        }
        if (bufferedData == null) {
          bufferedData=line;
        }
 else {
          bufferedData=bufferedData.concat(line);
        }
        if (line.equals("String_Node_Str")) {
          break;
        }
        if ("String_Node_Str".equals(lastLine) && line.equals("String_Node_Str")) {
          break;
        }
        lastLine=line;
      }
      if (bufferedData != null) {
        inputText.append(bufferedData);
        int idx=(bufferedData.length() < 50) ? bufferedData.length() : 50;
        s1=bufferedData.substring(0,idx);
        int i=s1.indexOf('\n');
        if (i > 0) {
          s1=s1.substring(0,i - 1);
        }
        s1=s1 + "String_Node_Str" + "String_Node_Str";
        s1=s1.substring(0,51);
        listener.tableModel.setValueAt(s1,index + 1,TCPMon.REQ_COLUMN);
      }
    }
    if (targetPort == -1) {
      targetPort=80;
    }
    outSocket=new Socket(targetHost,targetPort);
    tmpIn2=outSocket.getInputStream();
    tmpOut2=outSocket.getOutputStream();
    if (bufferedData != null) {
      byte[] b=bufferedData.getBytes();
      tmpOut2.write(b);
      slowLink.pump(b.length);
    }
    boolean format=listener.xmlFormatBox.isSelected();
    rr1=new SocketRR(this,inSocket,tmpIn1,outSocket,tmpOut2,inputText,format,listener.tableModel,index + 1,"String_Node_Str",slowLink);
    SlowLinkSimulator responseLink=new SlowLinkSimulator(slowLink);
    rr2=new SocketRR(this,outSocket,tmpIn2,inSocket,tmpOut1,outputText,format,null,0,"String_Node_Str",responseLink);
    while ((rr1 != null) || (rr2 != null)) {
      if (rr2 != null) {
        listener.tableModel.setValueAt(rr2.getElapsed(),1 + index,TCPMon.ELAPSED_COLUMN);
      }
      if ((null != rr1) && rr1.isDone()) {
        if ((index >= 0) && (rr2 != null)) {
          listener.tableModel.setValueAt(TCPMon.getMessage("String_Node_Str","String_Node_Str"),1 + index,TCPMon.STATE_COLUMN);
        }
        rr1=null;
      }
      if ((null != rr2) && rr2.isDone()) {
        if ((index >= 0) && (rr1 != null)) {
          listener.tableModel.setValueAt(TCPMon.getMessage("String_Node_Str","String_Node_Str"),1 + index,TCPMon.STATE_COLUMN);
        }
        rr2=null;
      }
synchronized (this) {
        this.wait(100);
      }
    }
    active=false;
    if (index >= 0) {
      listener.tableModel.setValueAt(TCPMon.getMessage("String_Node_Str","String_Node_Str"),1 + index,TCPMon.STATE_COLUMN);
    }
  }
 catch (  Exception e) {
    StringWriter st=new StringWriter();
    PrintWriter wr=new PrintWriter(st);
    int index=listener.connections.indexOf(this);
    if (index >= 0) {
      listener.tableModel.setValueAt(TCPMon.getMessage("String_Node_Str","String_Node_Str"),1 + index,TCPMon.STATE_COLUMN);
    }
    e.printStackTrace(wr);
    wr.close();
    if (outputText != null) {
      outputText.append(st.toString());
    }
 else {
      System.out.println(st.toString());
    }
    halt();
  }
}