Skip to content
This repository has been archived by the owner on Jun 10, 2019. It is now read-only.

Commit

Permalink
Improving logging in case of errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroigor committed Sep 10, 2014
1 parent a4e865c commit ad252f6
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
package org.picketlink.http.internal;

import org.jboss.logging.Logger;
import org.picketlink.Identity;
import org.picketlink.annotations.PicketLink;
import org.picketlink.authentication.AuthenticationException;
Expand Down Expand Up @@ -149,9 +150,9 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
throw new ServletException("This filter can only process HttpServletRequest requests.");
}

HttpServletRequest request = null;
HttpServletResponse response = null;
PathConfiguration pathConfiguration = null;
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;

try {
request = this.picketLinkHttpServletRequest.get();
Expand All @@ -160,7 +161,6 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
HTTP_LOGGER.debugf("Processing request to path [%s].", request.getRequestURI());
}

response = (HttpServletResponse) servletResponse;
pathConfiguration = this.pathMatcher.matches(request);

performAuthenticationIfRequired(pathConfiguration, request, response);
Expand Down Expand Up @@ -275,8 +275,8 @@ private void handleException(PathConfiguration pathConfiguration, HttpServletReq
message = "The server could not process your request.";
}

if (HTTP_LOGGER.isDebugEnabled()) {
HTTP_LOGGER.errorf("Exception [%s] thrown during processing for path [%s]. Sending error with status code [%s].", exception, request.getRequestURI(), statusCode);
if (HTTP_LOGGER.isEnabled(Logger.Level.ERROR)) {
HTTP_LOGGER.errorf(exception, "Exception thrown during processing for path [%s]. Sending error with status code [%s].", request.getRequestURI(), statusCode, exception);
}

response.sendError(statusCode, message);
Expand Down

0 comments on commit ad252f6

Please sign in to comment.