Source:
.RoutableDestination<HttpResourceModel> getDestinationMethod(String uri, String httpMethod, String contentTypeHeader, List<String> acceptHeader) throws HandlerException { try { String path = Utils.normalizePath(URI.create(uri).normalize().getPath()); List<PatternPathRouter.RoutableDestination<HttpResourceModel>> routableDestinations = patternRouter.getDestinations(path); List<PatternPathRouter.RoutableDestination<HttpResourceModel>> matchedDestinations = getMatchedDestination(routableDestinations, httpMethod, path); if (!matchedDestinations.isEmpty()) { if (matchedDestinations.size() == 1) { return matchedDestinations.stream().filter(matchedDestination1 -> matchedDestination1.getDestination() .matchConsumeMediaType( contentTypeHeader) && matchedDestination1.getDestination() .matchProduceMediaType( acceptHeader)) .findFirst().get(); } else { return matchedDestinations.stream().filter(matchedDestination1 -> matchedDestination1.getDestination() .matchConsumeMediaType( contentTypeHeader) && matchedDestination1.getDestination() .matchProduceMediaType( acceptHeader)) .filter(destination -> destination.getDestination().getHttpHandler() .getClass() == destination.getDestination().getMethod() .getDeclaringClass()).findFirst().get(); } } else if (!routableDestinations.isEmpty()) { throw new HandlerException(Response.Status.METHOD_NOT_ALLOWED, uri); } else { throw new HandlerException(Response.Status.NOT_FOUND, String.format("Problem accessing: %s. Reason2: Not Found", uri)); } } catch (NoSuchElementException ex) { throw new HandlerException(Response.Status.UNSUPPORTED_MEDIA_TYPE, String.format("Problem accessing: %s. Reason: Unsupported Media Type", uri), ex); } }

Target:
.RoutableDestination<HttpResourceModel> getDestinationMethod(String uri, String httpMethod, String contentTypeHeader, List<String> acceptHeader) throws HandlerException { try { String path = Utils.normalizePath(URI.create(uri).normalize().getPath()); List<PatternPathRouter.RoutableDestination<HttpResourceModel>> routableDestinations = patternRouter.getDestinations(path); List<PatternPathRouter.RoutableDestination<HttpResourceModel>> matchedDestinations = getMatchedDestination(routableDestinations, httpMethod, path); if (!matchedDestinations.isEmpty()) { if (matchedDestinations.size() == 1) { return matchedDestinations.stream().filter(matchedDestination1 -> matchedDestination1.getDestination() .matchConsumeMediaType( contentTypeHeader) && matchedDestination1.getDestination() .matchProduceMediaType( acceptHeader)) .findFirst().get(); } else { return matchedDestinations.stream().filter(matchedDestination1 -> matchedDestination1.getDestination() .matchConsumeMediaType( contentTypeHeader) && matchedDestination1.getDestination() .matchProduceMediaType( acceptHeader)) .filter(destination -> destination.getDestination().getHttpHandler() .getClass() == destination.getDestination().getMethod() .getDeclaringClass()).findFirst().get(); } } else if (!routableDestinations.isEmpty()) { throw new HandlerException(Response.Status.METHOD_NOT_ALLOWED, uri); } else { throw new HandlerException(Response.Status.NOT_FOUND, String.format("Problem accessing: %s. Reason: Not Found", uri)); } } catch (NoSuchElementException ex) { throw new HandlerException(Response.Status.UNSUPPORTED_MEDIA_TYPE, String.format("Problem accessing: %s. Reason: Unsupported Media Type", uri), ex); } }