Program: 152780
Project: 152780
Buggy source:
public void run(){
  curState=ThreadState.RUNNING;
  boolean initialized=waitUntilDbInitialized();
  if (initialized) {
    while (curState == ThreadState.RUNNING || curState == ThreadState.STOP_REQUESTED) {
      if (curState == ThreadState.STOP_REQUESTED) {
        LogLog.warn("String_Node_Str");
      }
      List<Entry> messages=db.getNext(batchSize);
      if (messages == null || messages.size() == 0) {
synchronized (waitLock) {
          try {
            waitLock.wait(1000);
          }
 catch (          InterruptedException e) {
            if (curState == ThreadState.STOP_REQUESTED) {
            }
 else {
              errorHandler.error("String_Node_Str",e,1);
            }
          }
        }
      }
 else {
        try {
          int response=sendData(messages);
switch (response) {
case 200:
case 201:
{
              db.deleteEntries(messages);
              break;
            }
case 400:
{
            LogLog.warn("String_Node_Str");
            db.deleteEntries(messages);
          }
default :
{
          LogLog.error("String_Node_Str" + response + "String_Node_Str");
        }
    }
  }
 catch (  IOException e) {
    errorHandler.error(String.format("String_Node_Str",logglyUrl),e,2);
  }
}
if (curState == ThreadState.STOP_REQUESTED) {
  curState=ThreadState.STOPPED;
}
 else if (requestedState == ThreadState.STOPPED) {
  curState=ThreadState.STOP_REQUESTED;
}
}
db.shutdown();
LogLog.warn("String_Node_Str");
}
 else {
LogLog.warn("String_Node_Str");
curState=ThreadState.STOPPED;
}
synchronized (stopLock) {
stopLock.notify();
}
}

Fixed version (ground truth):
public void run(){
  curState=ThreadState.RUNNING;
  LogLog.debug("String_Node_Str");
  boolean initialized=waitUntilDbInitialized();
  if (initialized) {
    LogLog.debug("String_Node_Str");
    List<Entry> messages=db.getNext(batchSize);
    while (curState == ThreadState.RUNNING || (curState == ThreadState.STOP_REQUESTED && messages != null && messages.size() > 0)) {
      if (curState == ThreadState.STOP_REQUESTED) {
        LogLog.warn("String_Node_Str" + messages.size());
      }
      if (messages == null || messages.size() == 0) {
synchronized (waitLock) {
          try {
            waitLock.wait(1000);
          }
 catch (          InterruptedException e) {
            if (curState == ThreadState.STOP_REQUESTED) {
            }
 else {
              errorHandler.error("String_Node_Str",e,1);
            }
          }
        }
      }
 else {
        try {
          int response=sendData(messages);
switch (response) {
case 200:
case 201:
{
              db.deleteEntries(messages);
              break;
            }
case 400:
{
            LogLog.warn("String_Node_Str");
            db.deleteEntries(messages);
          }
default :
{
          LogLog.error("String_Node_Str" + response + "String_Node_Str");
        }
    }
  }
 catch (  IOException e) {
    errorHandler.error(String.format("String_Node_Str",logglyUrl),e,2);
  }
}
if (curState == ThreadState.STOP_REQUESTED) {
  curState=ThreadState.STOPPED;
}
 else if (requestedState == ThreadState.STOPPED) {
  curState=ThreadState.STOP_REQUESTED;
}
messages=db.getNext(batchSize);
}
LogLog.debug("String_Node_Str");
}
 else {
LogLog.warn("String_Node_Str");
curState=ThreadState.STOPPED;
}
synchronized (stopLock) {
stopLock.notify();
}
}