diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/JSONResponseExceptionMapper.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/JSONResponseExceptionMapper.java index f86681ccb..8a2dcd4a1 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/JSONResponseExceptionMapper.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/JSONResponseExceptionMapper.java @@ -14,6 +14,7 @@ package org.openhab.core.io.rest.core.internal; import java.io.IOException; +import javax.ws.rs.NotFoundException; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; @@ -50,6 +51,12 @@ public class JSONResponseExceptionMapper implements ExceptionMapper { 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);