Program: 44234
Project: 44234
Buggy source:
public void run(){
  if (getConsumerState() == StreamConsumer.STATE_RESTARTING) {
    onRestarted();
  }
  int reconnect_delay=0;
  String reason="String_Node_Str";
  do {
    if ((getConsumerState() == StreamConsumer.STATE_RUNNING || getConsumerState() == StreamConsumer.STATE_RESTARTING) && reconnect_delay > 0) {
      try {
        Thread.sleep(reconnect_delay * 1000);
      }
 catch (      Exception e) {
      }
    }
    if (getConsumerState() == StreamConsumer.STATE_RUNNING) {
      try {
        if (_ws != null) {
          _ws.close();
        }
        _ws=null;
        _ws=new WebSocketConnection(_uri);
        _ws.addHeader("String_Node_Str" + _user.getUsername() + "String_Node_Str"+ _user.getAPIKey());
        _ws.addHeader("String_Node_Str" + _user.getUserAgent());
        _ws.setEventHandler(new WebSocketEventHandler(){
          public void onOpen(){
            _consumer.onConnect();
            for (            String hash : _subscriptions) {
              try {
                do_subscribe(hash);
              }
 catch (              EAPIError e) {
                try {
                  _consumer.onWarning("String_Node_Str" + hash);
                }
 catch (                EInvalidData e1) {
                }
              }
            }
          }
          public void onMessage(          WebSocketMessage message){
            String line=message.getText();
            if (line.length() > 10) {
              processLine(line);
            }
          }
          public void onClose(){
            _consumer.onDisconnect();
switch (getConsumerState()) {
case StreamConsumer.STATE_RUNNING:
              if (_auto_reconnect) {
                restartConsumer();
              }
 else {
                stopped();
              }
            break;
case StreamConsumer.STATE_STOPPING:
          stopped();
        break;
    }
  }
}
);
_ws.connect();
while (getConsumerState() == StreamConsumer.STATE_RUNNING) {
  Thread.sleep(500);
}
if (getConsumerState() != StreamConsumer.STATE_STOPPING && getConsumerState() != StreamConsumer.STATE_STOPPED) {
  stopConsumer();
  reason="String_Node_Str";
}
 else {
  reason="String_Node_Str";
}
int stopCounter=60;
while (stopCounter > 0 && getConsumerState() == StreamConsumer.STATE_STOPPING) {
  Thread.sleep(500);
  stopCounter--;
}
if (stopCounter == 0) {
synchronized (this) {
    try {
      _consumer.onWarning("String_Node_Str");
    }
 catch (    EInvalidData e) {
    }
  }
}
}
 catch (WebSocketException e) {
_auto_reconnect=false;
reason=e.getMessage();
}
catch (InterruptedException e) {
reason="String_Node_Str";
}
 finally {
try {
  _ws.close();
}
 catch (Exception e) {
}
}
}
if (reason.length() == 0 && (getConsumerState() == StreamConsumer.STATE_RUNNING || getConsumerState() == StreamConsumer.STATE_RESTARTING) && _auto_reconnect) {
if (reconnect_delay == 0) {
reconnect_delay=1;
}
 else if (reconnect_delay < 16) {
reconnect_delay++;
}
 else {
reason="String_Node_Str";
stopConsumer();
reconnect_delay=0;
}
if (reconnect_delay > 0) {
try {
  _consumer.onWarning("String_Node_Str" + reconnect_delay + "String_Node_Str");
}
 catch (EInvalidData e) {
}
}
}
}
 while ((getConsumerState() == StreamConsumer.STATE_RUNNING || getConsumerState() == StreamConsumer.STATE_RESTARTING) && _auto_reconnect);
if (reason.length() == 0) {
if (getConsumerState() == StreamConsumer.STATE_STOPPING) {
reason="String_Node_Str";
}
 else {
reason="String_Node_Str";
}
}
onStopped(reason);
}

Fixed version (ground truth):
public void run(){
  int reconnect_delay=0;
  String reason="String_Node_Str";
  do {
    if (getConsumerState() == StreamConsumer.STATE_RESTARTING) {
      onRestarted();
    }
    if ((getConsumerState() == StreamConsumer.STATE_RUNNING || getConsumerState() == StreamConsumer.STATE_RESTARTING) && reconnect_delay > 0) {
      try {
        Thread.sleep(reconnect_delay * 1000);
      }
 catch (      Exception e) {
      }
    }
    if (getConsumerState() == StreamConsumer.STATE_RUNNING) {
      try {
        if (_ws != null) {
          _ws.close();
        }
        _ws=null;
        _ws=new WebSocketConnection(_uri);
        _ws.addHeader("String_Node_Str" + _user.getUsername() + "String_Node_Str"+ _user.getAPIKey());
        _ws.addHeader("String_Node_Str" + _user.getUserAgent());
        _ws.setEventHandler(new WebSocketEventHandler(){
          public void onOpen(){
            _consumer.onConnect();
            for (            String hash : _subscriptions) {
              try {
                do_subscribe(hash);
              }
 catch (              EAPIError e) {
                try {
                  _consumer.onWarning("String_Node_Str" + hash);
                }
 catch (                EInvalidData e1) {
                }
              }
            }
          }
          public void onMessage(          WebSocketMessage message){
            String line=message.getText();
            if (line.length() > 10) {
              processLine(line);
            }
          }
          public void onClose(){
            _consumer.onDisconnect();
switch (getConsumerState()) {
case StreamConsumer.STATE_RUNNING:
              if (_auto_reconnect) {
                restartConsumer();
              }
 else {
                stopped();
              }
            break;
case StreamConsumer.STATE_STOPPING:
          stopped();
        break;
    }
  }
}
);
_ws.connect();
while (getConsumerState() == StreamConsumer.STATE_RUNNING) {
  Thread.sleep(500);
}
if (getConsumerState() != StreamConsumer.STATE_RESTARTING) {
  if (getConsumerState() != StreamConsumer.STATE_STOPPING && getConsumerState() != StreamConsumer.STATE_STOPPED) {
    stopConsumer();
    reason="String_Node_Str";
  }
 else {
    reason="String_Node_Str";
  }
}
int stopCounter=60;
while (stopCounter > 0 && getConsumerState() == StreamConsumer.STATE_STOPPING) {
  Thread.sleep(500);
  stopCounter--;
}
if (stopCounter == 0) {
synchronized (this) {
    try {
      _consumer.onWarning("String_Node_Str");
    }
 catch (    EInvalidData e) {
    }
  }
}
}
 catch (WebSocketException e) {
_auto_reconnect=false;
reason=e.getMessage();
}
catch (InterruptedException e) {
reason="String_Node_Str";
}
 finally {
try {
  _ws.close();
}
 catch (Exception e) {
}
}
}
if (reason.length() == 0 && (getConsumerState() == StreamConsumer.STATE_RUNNING || getConsumerState() == StreamConsumer.STATE_RESTARTING) && _auto_reconnect) {
if (reconnect_delay == 0) {
reconnect_delay=1;
}
 else if (reconnect_delay < 16) {
reconnect_delay++;
}
 else {
reason="String_Node_Str";
stopConsumer();
reconnect_delay=0;
}
if (reconnect_delay > 0) {
try {
  _consumer.onWarning("String_Node_Str" + reconnect_delay + "String_Node_Str");
}
 catch (EInvalidData e) {
}
}
}
}
 while ((getConsumerState() == StreamConsumer.STATE_RUNNING || getConsumerState() == StreamConsumer.STATE_RESTARTING) && _auto_reconnect);
if (reason.length() == 0) {
if (getConsumerState() == StreamConsumer.STATE_STOPPING) {
reason="String_Node_Str";
}
 else {
reason="String_Node_Str";
}
}
onStopped(reason);
}