Program: 153935
Project: 153935
Buggy source:
@Override protected Handshake newHandshakeInstance(){
  return new Handshake(){
    private ByteBuffer bodyBuf=ByteBuffer.allocate(16);
    /** 
 * Create a handshake requtest Sample (Draft76) client => server GET /demo HTTP/1.1 Host: example.com Connection: Upgrade Sec-WebSocket-Key2: 12998 5 Y3 1  .P00 Sec-WebSocket-Protocol: sample Upgrade: WebSocket Sec-WebSocket-Key1: 4 @1  46546xW%0l 1 5 Origin: http://example.com ^n:ds[4U
 * @param socket
 */
    @Override public ByteBuffer createHandshakeRequest(){
      bodyBuf.clear();
      StringBuilder sb=new StringBuilder();
      sb.append("String_Node_Str" + path + "String_Node_Str");
      addHeader(sb,"String_Node_Str",endpoint.getHostName());
      addHeader(sb,"String_Node_Str","String_Node_Str");
      addHeader(sb,"String_Node_Str","String_Node_Str");
      addHeader(sb,"String_Node_Str",SecWebSocketKey.generateKey());
      addHeader(sb,"String_Node_Str",SecWebSocketKey.generateKey());
      if (origin != null) {
        addHeader(sb,"String_Node_Str",origin);
      }
      if (protocols != null && protocols.length > 0) {
        addHeader(sb,"String_Node_Str",join("String_Node_Str",protocols));
      }
      sb.append("String_Node_Str");
      ByteBuffer buf=ByteBuffer.allocate(512);
      buf.put(sb.toString().getBytes());
      buf.put(SecWebSocketKey.generateKey3());
      buf.put((byte)0xd);
      buf.put((byte)0xa);
      buf.flip();
      return buf;
    }
    /** 
 * check handshake response server => client HTTP/1.1 101 WebSocket Protocol Handshake Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Origin: http://example.com Sec-WebSocket-Location: ws://example.com/demo Sec-WebSocket-Protocol: sample 8jKS'y:G*Co,Wxa-
 * @param buffer
 */
    @Override protected boolean parseHandshakeResponseHeader(    ByteBuffer buffer) throws WebSocketException {
      if (!super.parseHandshakeResponseHeader(buffer)) {
        return false;
      }
      if (!"String_Node_Str".equalsIgnoreCase(this.getResponseHeaderMap().get("String_Node_Str"))) {
        throw new WebSocketException(3101,"String_Node_Str" + responseHeaderMap.get("String_Node_Str"));
      }
      if (!"String_Node_Str".equalsIgnoreCase(this.getResponseHeaderMap().get("String_Node_Str"))) {
        throw new WebSocketException(3101,"String_Node_Str" + responseHeaderMap.get("String_Node_Str"));
      }
      String serverOrigin=this.getResponseHeaderMap().get("String_Node_Str");
      if (origin != null && serverOrigin != null && !serverOrigin.equals(origin)) {
        throw new WebSocketException(3101,"String_Node_Str" + origin + "String_Node_Str"+ serverOrigin);
      }
      String serverLocation=this.getResponseHeaderMap().get("String_Node_Str");
      try {
        URI uri=new URI(location.getScheme(),location.getHost(),location.getPath(),location.getFragment());
        if (serverLocation != null && !serverLocation.equals(uri.toString())) {
          throw new WebSocketException(3101,"String_Node_Str" + uri.toString() + "String_Node_Str"+ serverLocation);
        }
      }
 catch (      URISyntaxException e) {
        ;
      }
      String protocolStr=this.getResponseHeaderMap().get("String_Node_Str");
      if (protocolStr != null) {
        serverProtocols=protocolStr.split("String_Node_Str");
      }
      return true;
    }
    @Override protected boolean parseHandshakeResponseBody(    ByteBuffer buffer) throws WebSocketException {
      if (!super.parseHandshakeResponseBody(buffer)) {
        return false;
      }
      if (buffer.remaining() < bodyBuf.capacity()) {
        return false;
      }
      buffer.get(bodyBuf.array(),0,bodyBuf.capacity());
      return true;
    }
  }
;
}

Fixed version (ground truth):
@Override protected Handshake newHandshakeInstance(){
  return new Handshake(){
    private ByteBuffer bodyBuf=ByteBuffer.allocate(16);
    /** 
 * Create a handshake requtest <pre> Sample (Draft76) client => server GET /demo HTTP/1.1 Host: example.com Connection: Upgrade Sec-WebSocket-Key2: 12998 5 Y3 1  .P00 Sec-WebSocket-Protocol: sample Upgrade: WebSocket Sec-WebSocket-Key1: 4 @1  46546xW%0l 1 5 Origin: http://example.com ^n:ds[4U </pre>
 * @param socket
 */
    @Override public ByteBuffer createHandshakeRequest(){
      bodyBuf.clear();
      StringBuilder sb=new StringBuilder();
      sb.append("String_Node_Str" + path + "String_Node_Str");
      addHeader(sb,"String_Node_Str",endpoint.getHostName());
      addHeader(sb,"String_Node_Str","String_Node_Str");
      addHeader(sb,"String_Node_Str","String_Node_Str");
      addHeader(sb,"String_Node_Str",SecWebSocketKey.generateKey());
      addHeader(sb,"String_Node_Str",SecWebSocketKey.generateKey());
      if (origin != null) {
        addHeader(sb,"String_Node_Str",origin);
      }
      if (protocols != null && protocols.length > 0) {
        addHeader(sb,"String_Node_Str",join("String_Node_Str",protocols));
      }
      sb.append("String_Node_Str");
      ByteBuffer buf=ByteBuffer.allocate(512);
      buf.put(sb.toString().getBytes());
      buf.put(SecWebSocketKey.generateKey3());
      buf.put((byte)0xd);
      buf.put((byte)0xa);
      buf.flip();
      return buf;
    }
    /** 
 * check handshake response <pre> server => client HTTP/1.1 101 WebSocket Protocol Handshake Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Origin: http://example.com Sec-WebSocket-Location: ws://example.com/demo Sec-WebSocket-Protocol: sample 8jKS'y:G*Co,Wxa- </pre>
 * @param buffer
 */
    @Override protected boolean parseHandshakeResponseHeader(    ByteBuffer buffer) throws WebSocketException {
      if (!super.parseHandshakeResponseHeader(buffer)) {
        return false;
      }
      if (!"String_Node_Str".equalsIgnoreCase(this.getResponseHeaderMap().get("String_Node_Str"))) {
        throw new WebSocketException(3500,"String_Node_Str" + responseHeaderMap.get("String_Node_Str"));
      }
      if (!"String_Node_Str".equalsIgnoreCase(this.getResponseHeaderMap().get("String_Node_Str"))) {
        throw new WebSocketException(3501,"String_Node_Str" + responseHeaderMap.get("String_Node_Str"));
      }
      String serverOrigin=this.getResponseHeaderMap().get("String_Node_Str");
      if (origin != null && serverOrigin != null && !serverOrigin.equals(origin)) {
        throw new WebSocketException(3502,"String_Node_Str" + origin + "String_Node_Str"+ serverOrigin);
      }
      String serverLocation=this.getResponseHeaderMap().get("String_Node_Str");
      try {
        URI uri=new URI(location.getScheme(),location.getHost(),location.getPath(),location.getFragment());
        if (serverLocation != null && !serverLocation.equals(uri.toString())) {
          throw new WebSocketException(3503,"String_Node_Str" + uri.toString() + "String_Node_Str"+ serverLocation);
        }
      }
 catch (      URISyntaxException e) {
        ;
      }
      String protocolStr=this.getResponseHeaderMap().get("String_Node_Str");
      if (protocolStr != null) {
        serverProtocols=protocolStr.split("String_Node_Str");
      }
      return true;
    }
    @Override protected boolean parseHandshakeResponseBody(    ByteBuffer buffer) throws WebSocketException {
      if (!super.parseHandshakeResponseBody(buffer)) {
        return false;
      }
      if (buffer.remaining() < bodyBuf.capacity()) {
        return false;
      }
      buffer.get(bodyBuf.array(),0,bodyBuf.capacity());
      return true;
    }
  }
;
}