Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
NEXUS-4380: modified the exception handling to log only error conditi…
Browse files Browse the repository at this point in the history
…ons, if the exception to be handled is instance of ResourceException.
  • Loading branch information
cstamas authored and bdemers committed Jun 16, 2011
1 parent 01a2aa5 commit ed14eac
Showing 1 changed file with 15 additions and 5 deletions.
Expand Up @@ -373,9 +373,7 @@ protected Object renderItem( Context context, Request req, Response res, Variant
}
else
{
res.setStatus( Status.REDIRECTION_NOT_MODIFIED, "The resource is not modified!" );

return null;
throw new ResourceException( Status.REDIRECTION_NOT_MODIFIED, "Resource is not modified." );
}
}
else if ( req.getConditions().getNoneMatch() != null && req.getConditions().getNoneMatch().size() > 0
Expand Down Expand Up @@ -766,7 +764,7 @@ else if ( !o2.isLeaf() )
*
* @param t
*/
protected void handleException( Request req, Response res, Exception t )
protected void handleException( final Request req, final Response res, final Exception t )
throws ResourceException
{
// just set this flag to true in any if-else branch you want to see
Expand Down Expand Up @@ -835,6 +833,18 @@ else if ( t instanceof AccessDeniedException )
}
finally
{
if ( t instanceof ResourceException )
{
ResourceException re = (ResourceException) t;

if ( re.getStatus() != null && !re.getStatus().isError() )
{
// do not spam the log with non-error responses, we need only errors to have logged in case when
// exception to be handled is ResourceException
return;
}
}

String message =
"Got exception during processing request \"" + req.getMethod() + " " + req.getResourceRef().toString()
+ "\": ";
Expand Down Expand Up @@ -887,7 +897,7 @@ else if ( t instanceof AccessDeniedException )
* @param res
* @param t
*/
public static void challengeIfNeeded( Request req, Response res, AccessDeniedException t )
public static void challengeIfNeeded( final Request req, final Response res, final AccessDeniedException t )
{
// TODO: a big fat problem here!
// this makes restlet code tied to Servlet code, and we what is happening here is VERY dirty!
Expand Down

0 comments on commit ed14eac

Please sign in to comment.