Program: 99346
Project: 99346
Buggy source:
@Override protected ViewModel doPost(HttpServletRequest request,HttpServletResponse response) throws Exception {
  String json;
  AuthenticationRequest authcRequest=null;
  AccessTokenResult result=null;
  try {
    assertAuthorized(request,response);
    String grantType=null;
    try {
      grantType=request.getParameter(GRANT_TYPE_PARAM_NAME);
      Assert.hasText(grantType,"String_Node_Str");
    }
 catch (    IllegalArgumentException e) {
      throw new OAuthException(OAuthErrorCode.INVALID_GRANT);
    }
    grantTypeValidator.validate(grantType);
switch (grantType) {
case PASSWORD_GRANT_TYPE:
      result=this.tokenAuthenticationRequest(request,response);
    break;
case REFRESH_TOKEN_GRANT_TYPE:
  result=this.refreshTokenAuthenticationRequest(request,response);
break;
case CLIENT_CREDENTIALS_GRANT_TYPE:
try {
result=this.clientCredentialsAuthenticationRequest(request,response);
}
 catch (HttpAuthenticationException e) {
log.warn("String_Node_Str",e);
throw new OAuthException(OAuthErrorCode.INVALID_CLIENT);
}
break;
case STORMPATH_SOCIAL_GRANT_TYPE:
try {
result=this.stormpathSocialAuthenticationRequest(request,response);
}
 catch (HttpAuthenticationException e) {
log.warn("String_Node_Str",e);
throw new OAuthException(OAuthErrorCode.INVALID_CLIENT);
}
break;
default :
throw new OAuthException(OAuthErrorCode.UNSUPPORTED_GRANT_TYPE,"String_Node_Str" + grantType + "String_Node_Str");
}
saveResult(request,response,result);
json=result.getTokenResponse().toJson();
response.setStatus(HttpServletResponse.SC_OK);
SuccessfulAuthenticationRequestEvent e=createSuccessEvent(request,response,authcRequest,result);
publish(e);
}
 catch (OAuthException e) {
log.debug("String_Node_Str",e.getMessage());
json=e.toJson();
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
if (e.getErrorCode().equals(OAuthErrorCode.INVALID_CLIENT)) {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
try {
FailedAuthenticationRequestEvent evt=new DefaultFailedAuthenticationRequestEvent(request,response,authcRequest,e);
publish(evt);
}
 catch (Throwable t) {
log.warn("String_Node_Str",t,e,t);
}
}
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setHeader("String_Node_Str","String_Node_Str");
response.setHeader("String_Node_Str","String_Node_Str");
response.setHeader("String_Node_Str",String.valueOf(json.length()));
response.getWriter().print(json);
response.getWriter().flush();
return null;
}

Fixed version (ground truth):
@Override protected ViewModel doPost(HttpServletRequest request,HttpServletResponse response) throws Exception {
  String json;
  AuthenticationRequest authcRequest=null;
  AccessTokenResult result;
  try {
    assertAuthorized(request,response);
    String grantType;
    try {
      grantType=request.getParameter(GRANT_TYPE_PARAM_NAME);
      Assert.hasText(grantType,"String_Node_Str");
    }
 catch (    IllegalArgumentException e) {
      throw new OAuthException(OAuthErrorCode.INVALID_GRANT);
    }
    grantTypeValidator.validate(grantType);
switch (grantType) {
case PASSWORD_GRANT_TYPE:
      result=this.tokenAuthenticationRequest(request,response);
    break;
case REFRESH_TOKEN_GRANT_TYPE:
  result=this.refreshTokenAuthenticationRequest(request,response);
break;
case CLIENT_CREDENTIALS_GRANT_TYPE:
try {
result=this.clientCredentialsAuthenticationRequest(request,response);
}
 catch (HttpAuthenticationException e) {
log.warn("String_Node_Str",e);
throw new OAuthException(OAuthErrorCode.INVALID_CLIENT);
}
break;
case STORMPATH_SOCIAL_GRANT_TYPE:
try {
result=this.stormpathSocialAuthenticationRequest(request,response);
}
 catch (HttpAuthenticationException e) {
log.warn("String_Node_Str",e);
throw new OAuthException(OAuthErrorCode.INVALID_CLIENT);
}
break;
default :
throw new OAuthException(OAuthErrorCode.UNSUPPORTED_GRANT_TYPE,"String_Node_Str" + grantType + "String_Node_Str");
}
saveResult(request,response,result);
json=result.getTokenResponse().toJson();
response.setStatus(HttpServletResponse.SC_OK);
SuccessfulAuthenticationRequestEvent e=createSuccessEvent(request,response,authcRequest,result);
publish(e);
}
 catch (OAuthException e) {
log.debug("String_Node_Str",e.getMessage());
json=e.toJson();
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
if (e.getErrorCode().equals(OAuthErrorCode.INVALID_CLIENT)) {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
try {
FailedAuthenticationRequestEvent evt=new DefaultFailedAuthenticationRequestEvent(request,response,authcRequest,e);
publish(evt);
}
 catch (Throwable t) {
log.warn("String_Node_Str",t,e,t);
}
}
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setHeader("String_Node_Str","String_Node_Str");
response.setHeader("String_Node_Str","String_Node_Str");
response.setHeader("String_Node_Str",String.valueOf(json.length()));
response.getWriter().print(json);
response.getWriter().flush();
return null;
}