Program: 20487
Project: 20487
Buggy source:
/** 
 * Initializes the connection by creating a packet reader and writer and opening a XMPP stream to the server.
 * @throws XMPPException if establishing a connection to the server fails.
 */
private void init() throws XMPPException {
  try {
    reader=new BufferedReader(new InputStreamReader(socket.getInputStream(),"String_Node_Str"));
    writer=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(),"String_Node_Str"));
  }
 catch (  IOException ioe) {
    throw new XMPPException("String_Node_Str",new XMPPError(502),ioe);
  }
  if (DEBUG_ENABLED) {
    String className=null;
    try {
      System.getProperty("String_Node_Str");
    }
 catch (    Throwable t) {
    }
    Class debuggerClass=null;
    if (className != null) {
      try {
        debuggerClass=Class.forName(className);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
    if (debuggerClass == null) {
      try {
        debuggerClass=Class.forName("String_Node_Str");
      }
 catch (      Exception ex) {
        try {
          debuggerClass=Class.forName("String_Node_Str");
        }
 catch (        Exception ex2) {
          ex2.printStackTrace();
        }
      }
    }
    try {
      Constructor constructor=debuggerClass.getConstructor(new Class[]{XMPPConnection.class,Writer.class,Reader.class});
      debugger=(SmackDebugger)constructor.newInstance(new Object[]{this,writer,reader});
      reader=debugger.getReader();
      writer=debugger.getWriter();
    }
 catch (    Exception e) {
      e.printStackTrace();
      DEBUG_ENABLED=false;
    }
  }
  try {
    packetWriter=new PacketWriter(this);
    packetReader=new PacketReader(this);
    if (DEBUG_ENABLED) {
      packetReader.addPacketListener(debugger.getReaderListener(),null);
      if (debugger.getWriterListener() != null) {
        packetWriter.addPacketListener(debugger.getWriterListener(),null);
      }
    }
    packetWriter.startup();
    packetReader.startup();
    connected=true;
    connectionEstablished(this);
  }
 catch (  XMPPException ex) {
    if (packetWriter != null) {
      try {
        packetWriter.shutdown();
      }
 catch (      Throwable ignore) {
      }
      packetWriter=null;
    }
    if (packetReader != null) {
      try {
        packetReader.shutdown();
      }
 catch (      Throwable ignore) {
      }
      packetReader=null;
    }
    if (reader != null) {
      try {
        reader.close();
      }
 catch (      Throwable ignore) {
      }
      reader=null;
    }
    if (writer != null) {
      try {
        writer.close();
      }
 catch (      Throwable ignore) {
      }
      writer=null;
    }
    if (socket != null) {
      try {
        socket.close();
      }
 catch (      Exception e) {
      }
      socket=null;
    }
    authenticated=false;
    connected=false;
    throw ex;
  }
}

Fixed version (ground truth):
/** 
 * Initializes the connection by creating a packet reader and writer and opening a XMPP stream to the server.
 * @throws XMPPException if establishing a connection to the server fails.
 */
private void init() throws XMPPException {
  try {
    reader=new BufferedReader(new InputStreamReader(socket.getInputStream(),"String_Node_Str"));
    writer=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(),"String_Node_Str"));
  }
 catch (  IOException ioe) {
    throw new XMPPException("String_Node_Str",new XMPPError(502),ioe);
  }
  if (DEBUG_ENABLED) {
    String className=null;
    try {
      className=System.getProperty("String_Node_Str");
    }
 catch (    Throwable t) {
    }
    Class debuggerClass=null;
    if (className != null) {
      try {
        debuggerClass=Class.forName(className);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
    if (debuggerClass == null) {
      try {
        debuggerClass=Class.forName("String_Node_Str");
      }
 catch (      Exception ex) {
        try {
          debuggerClass=Class.forName("String_Node_Str");
        }
 catch (        Exception ex2) {
          ex2.printStackTrace();
        }
      }
    }
    try {
      Constructor constructor=debuggerClass.getConstructor(new Class[]{XMPPConnection.class,Writer.class,Reader.class});
      debugger=(SmackDebugger)constructor.newInstance(new Object[]{this,writer,reader});
      reader=debugger.getReader();
      writer=debugger.getWriter();
    }
 catch (    Exception e) {
      e.printStackTrace();
      DEBUG_ENABLED=false;
    }
  }
  try {
    packetWriter=new PacketWriter(this);
    packetReader=new PacketReader(this);
    if (DEBUG_ENABLED) {
      packetReader.addPacketListener(debugger.getReaderListener(),null);
      if (debugger.getWriterListener() != null) {
        packetWriter.addPacketListener(debugger.getWriterListener(),null);
      }
    }
    packetWriter.startup();
    packetReader.startup();
    connected=true;
    connectionEstablished(this);
  }
 catch (  XMPPException ex) {
    if (packetWriter != null) {
      try {
        packetWriter.shutdown();
      }
 catch (      Throwable ignore) {
      }
      packetWriter=null;
    }
    if (packetReader != null) {
      try {
        packetReader.shutdown();
      }
 catch (      Throwable ignore) {
      }
      packetReader=null;
    }
    if (reader != null) {
      try {
        reader.close();
      }
 catch (      Throwable ignore) {
      }
      reader=null;
    }
    if (writer != null) {
      try {
        writer.close();
      }
 catch (      Throwable ignore) {
      }
      writer=null;
    }
    if (socket != null) {
      try {
        socket.close();
      }
 catch (      Exception e) {
      }
      socket=null;
    }
    authenticated=false;
    connected=false;
    throw ex;
  }
}