Program: 86419
Project: 86419
Buggy source:
/** 
 * On successful authentication by an Authentication Manager of Spring Security we intercept with this method  and change the respone to include the ROLES of the logged in user. This way we can react on the ROLES and redirect accordingly within the requesting login form (here login.js)
 * @see WebContent/client/login.js
 */
@Override protected void successfulAuthentication(HttpServletRequest request,HttpServletResponse response,Authentication authResult) throws IOException, ServletException {
  SecurityContextHolder.getContext().setAuthentication(authResult);
  SavedRequestAwareAuthenticationSuccessHandler srh=new SavedRequestAwareAuthenticationSuccessHandler();
  this.setAuthenticationSuccessHandler(srh);
  srh.setRedirectStrategy(new RedirectStrategy(){
    @Override public void sendRedirect(    HttpServletRequest httpServletRequest,    HttpServletResponse httpServletResponse,    String s) throws IOException {
    }
  }
);
  super.successfulAuthentication(request,response,authResult);
  String authorityText=StringUtils.join(authResult.getAuthorities(),"String_Node_Str");
  HttpServletResponseWrapper responseWrapper=new HttpServletResponseWrapper(response);
  JsonGenerator jsonGenerator=null;
  Writer out=null;
  try {
    out=responseWrapper.getWriter();
    JsonFactory jsonFactory=new JsonFactory();
    jsonGenerator=jsonFactory.createGenerator(out);
    jsonGenerator.writeStartObject();
    jsonGenerator.writeBooleanField("String_Node_Str",true);
    jsonGenerator.writeStringField("String_Node_Str",authResult.getName());
    jsonGenerator.writeStringField("String_Node_Str",authorityText);
    jsonGenerator.writeEndObject();
  }
 catch (  IOException e) {
    throw e;
  }
 finally {
    IOUtils.closeQuietly(out);
    IOUtils.closeQuietly(jsonGenerator);
  }
}

Fixed version (ground truth):
/** 
 * On successful authentication by an Authentication Manager of Spring Security we intercept with this method  and change the respone to include the ROLES of the logged in user. This way we can react on the ROLES and redirect accordingly within the requesting login form (here login.js)
 * @see WebContent/client/login.js
 */
@Override protected void successfulAuthentication(HttpServletRequest request,HttpServletResponse response,Authentication authResult) throws IOException, ServletException {
  SecurityContextHolder.getContext().setAuthentication(authResult);
  SavedRequestAwareAuthenticationSuccessHandler srh=new SavedRequestAwareAuthenticationSuccessHandler();
  this.setAuthenticationSuccessHandler(srh);
  srh.setRedirectStrategy(new RedirectStrategy(){
    @Override public void sendRedirect(    HttpServletRequest httpServletRequest,    HttpServletResponse httpServletResponse,    String s) throws IOException {
    }
  }
);
  super.successfulAuthentication(request,response,authResult);
  response.setContentType("String_Node_Str");
  String authorityText=StringUtils.join(authResult.getAuthorities(),"String_Node_Str");
  HttpServletResponseWrapper responseWrapper=new HttpServletResponseWrapper(response);
  JsonGenerator jsonGenerator=null;
  Writer out=null;
  try {
    out=responseWrapper.getWriter();
    JsonFactory jsonFactory=new JsonFactory();
    jsonGenerator=jsonFactory.createGenerator(out);
    jsonGenerator.writeStartObject();
    jsonGenerator.writeBooleanField("String_Node_Str",true);
    jsonGenerator.writeStringField("String_Node_Str",authResult.getName());
    jsonGenerator.writeStringField("String_Node_Str",authorityText);
    jsonGenerator.writeEndObject();
  }
 catch (  IOException e) {
    throw e;
  }
 finally {
    IOUtils.closeQuietly(jsonGenerator);
    IOUtils.closeQuietly(out);
  }
}