X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=restconf%2Frestconf-nb-bierman02%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Frest%2Fimpl%2FRestconfDocumentedExceptionMapper.java;h=b4b2890954284b42da9d46bbeda7192f9cbaeabb;hb=b03d2347a1d39f769ec310256f8dea31ac358632;hp=c271bf33d2d28c856df14065f5574525ae40042d;hpb=14a7a2a95476ed2e7c174fdfd89bcc9815d48051;p=netconf.git diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDocumentedExceptionMapper.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDocumentedExceptionMapper.java index c271bf33d2..b4b2890954 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDocumentedExceptionMapper.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDocumentedExceptionMapper.java @@ -99,20 +99,8 @@ public class RestconfDocumentedExceptionMapper implements ExceptionMapper accepts = headers.getAcceptableMediaTypes(); - if (accepts != null) { - accepts.remove(MediaType.WILDCARD_TYPE); - } - - LOG.debug("Accept headers: {}", accepts); - - final MediaType mediaType; - if (accepts != null && accepts.size() > 0) { - mediaType = accepts.get(0); // just pick the first one - } else { - // Default to the content type if there's no Accept header - mediaType = MediaType.APPLICATION_JSON_TYPE; - } + final MediaType mediaType = headers.getAcceptableMediaTypes().stream() + .filter(type -> type != MediaType.WILDCARD_TYPE).findFirst().orElse(MediaType.APPLICATION_JSON_TYPE); LOG.debug("Using MediaType: {}", mediaType);