Fixing errors check in RestconfDocumentedExceptionMapper 23/92423/6
authorJaroslav Tóth <jtoth@frinx.io>
Fri, 22 May 2020 11:42:22 +0000 (13:42 +0200)
committerJaroslav T�th <jtoth@frinx.io>
Mon, 25 Jan 2021 18:19:04 +0000 (18:19 +0000)
- Added check for number of errors that should not equal to 0;
  otherwise warning logs are generated.

Change-Id: I5e173d6389c0b17b278aae8abb0d585cb45e21d1
Signed-off-by: Jaroslav Tóth <jtoth@frinx.io>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/errors/RestconfDocumentedExceptionMapper.java

index b5d713f5ece4dbbfa429e0c705ac93aa0a848a9e..2090bdac734dcc4f376ab6d8a63c142ef58b93d9 100644 (file)
@@ -90,7 +90,8 @@ public final class RestconfDocumentedExceptionMapper implements ExceptionMapper<
         LOG.debug("Starting to map received exception to error response: {}", exception.getMessage());
         final Status responseStatus = getResponseStatusCode(exception);
         if (responseStatus != Response.Status.FORBIDDEN
-                && responseStatus.getFamily() == Response.Status.Family.CLIENT_ERROR) {
+                && responseStatus.getFamily() == Response.Status.Family.CLIENT_ERROR
+                && exception.getErrors().isEmpty()) {
             // there should be at least one error entry for 4xx errors except 409 according to the RFC 8040
             // - creation of WARN log that something went wrong way on the server side
             LOG.warn("Input exception has a family of 4xx but doesn't contain any descriptive errors: {}",