Skip to content

Commit

Permalink
Don't log errors on NotFoundExceptions in Jetty (#3931)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikreuzer authored Dec 19, 2023
1 parent cb1b355 commit 04cd840
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.io.IOException;

import javax.ws.rs.NotFoundException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;

Expand Down Expand Up @@ -50,6 +51,12 @@ public class JSONResponseExceptionMapper implements ExceptionMapper<Exception> {
logger.debug("Failed writing HTTP response, since other side closed the connection", e);
// Returning null results in a Response.Status.NO_CONTENT response.
return null;
} else if (e instanceof NotFoundException) {
// we catch this exception to avoid confusion errors in the log file, since this is not any error situation
// see https://github.com/openhab/openhab-distro/issues/1616
logger.debug("Requested resource not (yet) found", e);
// Returning null results in a Response.Status.NO_CONTENT response.
return Response.status(Response.Status.NOT_FOUND).build();
} else {
logger.error("Unexpected exception occurred while processing REST request.", e);
return delegate.toResponse(e);
Expand Down

0 comments on commit 04cd840

Please sign in to comment.