Program: 31027
Project: 31027
Buggy source:
private void handshake() throws IOException {
  if (handshakeStatus == SSLEngineResult.HandshakeStatus.FINISHED) {
    return;
  }
  engine.beginHandshake();
  while (handshakeStatus != SSLEngineResult.HandshakeStatus.FINISHED) {
switch (handshakeStatus) {
case NOT_HANDSHAKING:
      throw new IOException("String_Node_Str");
case NEED_WRAP:
    outBuf.clear();
  swapBuf.clear();
try {
  handshakeStatus=engine.wrap(swapBuf,outBuf).getHandshakeStatus();
}
 catch (SSLException e) {
  LOG.error().$("String_Node_Str").$(e.getMessage()).$();
  closureOnException();
  throw e;
}
outBuf.flip();
socketChannel.write(outBuf);
break;
case NEED_UNWRAP:
if (!inData || !inBuf.hasRemaining()) {
inBuf.clear();
socketChannel.read(inBuf);
inBuf.flip();
inData=true;
}
try {
SSLEngineResult res=engine.unwrap(inBuf,swapBuf);
handshakeStatus=res.getHandshakeStatus();
switch (res.getStatus()) {
case BUFFER_UNDERFLOW:
inBuf.compact();
socketChannel.read(inBuf);
inBuf.flip();
break;
case BUFFER_OVERFLOW:
throw new IOException("String_Node_Str");
case OK:
break;
case CLOSED:
throw new IOException("String_Node_Str");
default :
break;
}
}
 catch (SSLException e) {
LOG.error().$("String_Node_Str").$(e.getMessage()).$();
throw e;
}
break;
case NEED_TASK:
Runnable task;
while ((task=engine.getDelegatedTask()) != null) {
task.run();
}
handshakeStatus=engine.getHandshakeStatus();
break;
default :
throw new JournalRuntimeException("String_Node_Str",handshakeStatus);
}
}
inBuf.clear();
swapBuf.position(swapBuf.limit());
LOG.info().$("String_Node_Str").$(client ? "String_Node_Str" : "String_Node_Str").$();
}

Fixed version (ground truth):
private void handshake() throws IOException {
  if (handshakeStatus == SSLEngineResult.HandshakeStatus.FINISHED) {
    return;
  }
  engine.beginHandshake();
  while (handshakeStatus != SSLEngineResult.HandshakeStatus.FINISHED) {
switch (handshakeStatus) {
case NOT_HANDSHAKING:
      throw new IOException("String_Node_Str");
case NEED_WRAP:
    outBuf.clear();
  swapBuf.clear();
try {
  handshakeStatus=engine.wrap(swapBuf,outBuf).getHandshakeStatus();
}
 catch (SSLException e) {
  LOG.error().$("String_Node_Str").$(e.getMessage()).$();
  closureOnException();
  socketChannel.close();
  throw e;
}
outBuf.flip();
socketChannel.write(outBuf);
break;
case NEED_UNWRAP:
if (!inData || !inBuf.hasRemaining()) {
inBuf.clear();
socketChannel.read(inBuf);
inBuf.flip();
inData=true;
}
try {
SSLEngineResult res=engine.unwrap(inBuf,swapBuf);
handshakeStatus=res.getHandshakeStatus();
switch (res.getStatus()) {
case BUFFER_UNDERFLOW:
inBuf.compact();
socketChannel.read(inBuf);
inBuf.flip();
break;
case BUFFER_OVERFLOW:
throw new IOException("String_Node_Str");
case OK:
break;
case CLOSED:
throw new IOException("String_Node_Str");
default :
break;
}
}
 catch (SSLException e) {
LOG.error().$("String_Node_Str").$(e.getMessage()).$();
handshakeStatus=SSLEngineResult.HandshakeStatus.FINISHED;
socketChannel.close();
throw e;
}
break;
case NEED_TASK:
Runnable task;
while ((task=engine.getDelegatedTask()) != null) {
task.run();
}
handshakeStatus=engine.getHandshakeStatus();
break;
default :
throw new JournalRuntimeException("String_Node_Str",handshakeStatus);
}
}
inBuf.clear();
swapBuf.position(swapBuf.limit());
LOG.info().$("String_Node_Str").$(client ? "String_Node_Str" : "String_Node_Str").$();
}