Program: 24249
Project: 24249
Buggy source:
@Override protected Object encode(ChannelHandlerContext ctx,Channel channel,Object msg) throws Exception {
  if (msg instanceof ControlMessage) {
    ControlMessage controlMessage=(ControlMessage)msg;
switch (controlMessage.getKind()) {
case PREPARED:
      return createHttpResponse((ChannelBuffer)encodeMessageWithoutContent(ctx,channel,controlMessage));
case STARTED:
    return createHttpResponse((ChannelBuffer)encodeMessageWithoutContent(ctx,channel,controlMessage));
case ERROR:
  return createHttpResponse((ChannelBuffer)encodeErrorMessage(ctx,channel,(ErrorMessage)controlMessage));
case FINISHED:
ChannelBuffer header=(ChannelBuffer)encodeFinishedMessage(ctx,channel,(FinishedMessage)controlMessage);
scriptResultCache.put(controlMessage.getName(),createHttpResponse(header));
return ChannelBuffers.EMPTY_BUFFER;
case RESULT_REQUEST:
if (scriptResultCache.containsKey(controlMessage.getName()) && (lastResultRequestName == null || System.currentTimeMillis() - lastResultRequestTime.getTime() <= 500)) {
lastResultRequestName=controlMessage.getName();
lastResultRequestTime=new Date();
scheduler.schedule(clearLastRequestEntry,500,TimeUnit.MILLISECONDS);
return scriptResultCache.get(controlMessage.getName());
}
 else if (lastResultRequestName != null && lastResultRequestName.equals(controlMessage.getName())) {
BadRequestMessage badRequest=new BadRequestMessage();
badRequest.setName(controlMessage.getName());
badRequest.setContent("String_Node_Str");
return encodeBadRequestMessage(ctx,channel,badRequest);
}
 else {
ErrorMessage errorMessage=new ErrorMessage();
errorMessage.setName(controlMessage.getName());
errorMessage.setDescription("String_Node_Str");
errorMessage.setSummary("String_Node_Str");
return createHttpResponse((ChannelBuffer)encodeErrorMessage(ctx,channel,errorMessage));
}
case BAD_REQUEST:
return encodeBadRequestMessage(ctx,channel,(BadRequestMessage)controlMessage);
case CLEAR_CACHE:
scriptResultCache.clear();
lastResultRequestTime=null;
lastResultRequestName=null;
return ChannelBuffers.EMPTY_BUFFER;
default :
break;
}
}
return msg;
}

Fixed version (ground truth):
@Override protected Object encode(ChannelHandlerContext ctx,Channel channel,Object msg) throws Exception {
  if (msg instanceof ControlMessage) {
    ControlMessage controlMessage=(ControlMessage)msg;
switch (controlMessage.getKind()) {
case PREPARED:
      return createHttpResponse((ChannelBuffer)encodeMessageWithoutContent(ctx,channel,controlMessage));
case STARTED:
    return createHttpResponse((ChannelBuffer)encodeMessageWithoutContent(ctx,channel,controlMessage));
case ERROR:
  return createHttpResponse((ChannelBuffer)encodeErrorMessage(ctx,channel,(ErrorMessage)controlMessage));
case FINISHED:
ChannelBuffer header=(ChannelBuffer)encodeFinishedMessage(ctx,channel,(FinishedMessage)controlMessage);
scriptResultCache.put(controlMessage.getName(),createHttpResponse(header));
return ChannelBuffers.EMPTY_BUFFER;
case RESULT_REQUEST:
if (scriptResultCache.containsKey(controlMessage.getName()) && (lastResultRequestName == null || System.currentTimeMillis() - lastResultRequestTime.getTime() <= TIME_LIMIT_MILLIS)) {
lastResultRequestName=controlMessage.getName();
lastResultRequestTime=new Date();
scheduler.schedule(clearLastRequestEntry,TIME_LIMIT_MILLIS,TimeUnit.MILLISECONDS);
return scriptResultCache.get(controlMessage.getName());
}
 else if (lastResultRequestName != null && lastResultRequestName.equals(controlMessage.getName())) {
BadRequestMessage badRequest=new BadRequestMessage();
badRequest.setName(controlMessage.getName());
badRequest.setContent("String_Node_Str");
return encodeBadRequestMessage(ctx,channel,badRequest);
}
 else {
ErrorMessage errorMessage=new ErrorMessage();
errorMessage.setName(controlMessage.getName());
errorMessage.setDescription("String_Node_Str");
errorMessage.setSummary("String_Node_Str");
return createHttpResponse((ChannelBuffer)encodeErrorMessage(ctx,channel,errorMessage));
}
case BAD_REQUEST:
return encodeBadRequestMessage(ctx,channel,(BadRequestMessage)controlMessage);
case CLEAR_CACHE:
scriptResultCache.clear();
lastResultRequestTime=null;
lastResultRequestName=null;
return ChannelBuffers.EMPTY_BUFFER;
default :
break;
}
}
return msg;
}