Program: 178233
Project: 178233
Buggy source:
private void openSerialConnection(String portName){
  int baudRate=19200;
  serialInStream=null;
  serialOutStream=null;
  Debug.d("String_Node_Str" + portName);
  Main.setRepRapPresent(false);
  try {
    CommPortIdentifier commId=CommPortIdentifier.getPortIdentifier(portName);
    port=(SerialPort)commId.open(portName,30000);
  }
 catch (  NoSuchPortException e) {
    Debug.d("String_Node_Str" + portName + "String_Node_Str");
    return;
  }
catch (  PortInUseException e) {
    Debug.e("String_Node_Str" + portName + "String_Node_Str");
    return;
  }
  Main.setRepRapPresent(true);
  try {
    baudRate=Preferences.loadGlobalInt("String_Node_Str");
  }
 catch (  IOException e) {
  }
  try {
    port.setSerialPortParams(baudRate,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
  }
 catch (  UnsupportedCommOperationException e) {
    Debug.d("String_Node_Str" + e.toString());
    return;
  }
  try {
    port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
  }
 catch (  Exception e) {
  }
  try {
    port.enableReceiveTimeout(1);
  }
 catch (  UnsupportedCommOperationException e) {
    Debug.d("String_Node_Str");
  }
  try {
    OutputStream writeStream=port.getOutputStream();
    serialInStream=port.getInputStream();
    serialOutStream=new PrintStream(writeStream);
  }
 catch (  IOException e) {
    Debug.e("String_Node_Str");
    serialInStream=null;
    serialOutStream=null;
    return;
  }
  Debug.d("String_Node_Str");
  try {
    Thread.sleep(1000);
  }
 catch (  Exception e) {
  }
  for (int i=0; i < 10; i++)   serialOutStream.write('0');
  try {
    Thread.sleep(1000);
  }
 catch (  Exception e) {
  }
  return;
}

Fixed version (ground truth):
private void openSerialConnection(String portName){
  int baudRate=19200;
  serialInStream=null;
  serialOutStream=null;
  Debug.d("String_Node_Str" + portName);
  Main.setRepRapPresent(false);
  try {
    CommPortIdentifier commId=CommPortIdentifier.getPortIdentifier(portName);
    port=(SerialPort)commId.open(portName,30000);
  }
 catch (  NoSuchPortException e) {
    Debug.d("String_Node_Str" + portName + "String_Node_Str");
    return;
  }
catch (  PortInUseException e) {
    Debug.e("String_Node_Str" + portName + "String_Node_Str");
    return;
  }
  Main.setRepRapPresent(true);
  try {
    baudRate=Preferences.loadGlobalInt("String_Node_Str");
  }
 catch (  IOException e) {
  }
  try {
    port.setSerialPortParams(baudRate,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
  }
 catch (  UnsupportedCommOperationException e) {
    Debug.d("String_Node_Str" + e.toString());
    return;
  }
  try {
    Thread.sleep(1000);
  }
 catch (  Exception e) {
  }
  try {
    port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
  }
 catch (  Exception e) {
  }
  try {
    port.enableReceiveTimeout(1);
  }
 catch (  UnsupportedCommOperationException e) {
    Debug.d("String_Node_Str");
  }
  try {
    OutputStream writeStream=port.getOutputStream();
    serialInStream=port.getInputStream();
    serialOutStream=new PrintStream(writeStream);
  }
 catch (  IOException e) {
    Debug.e("String_Node_Str");
    serialInStream=null;
    serialOutStream=null;
    return;
  }
  Debug.d("String_Node_Str");
  try {
    Thread.sleep(1000);
  }
 catch (  Exception e) {
  }
  for (int i=0; i < 10; i++)   serialOutStream.write('0');
  try {
    Thread.sleep(1000);
  }
 catch (  Exception e) {
  }
  return;
}