diff options
Diffstat (limited to 'vespaclient-container-plugin')
-rw-r--r-- | vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandler.java | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandler.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandler.java index 6cddba59a6c..5052692a379 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandler.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandler.java @@ -118,12 +118,10 @@ public class FeedHandler extends LoggingRequestHandler { if (versionHeader != null) { return Optional.of(versionHeader); } - String userAgentHeader = request.getHeader("User-Agent"); - Matcher matcher = USER_AGENT_PATTERN.matcher(userAgentHeader); - if (matcher.matches()) { - return Optional.of(matcher.group(1)); - } - return Optional.empty(); + return Optional.ofNullable(request.getHeader("User-Agent")) + .map(USER_AGENT_PATTERN::matcher) + .filter(Matcher::matches) + .map(matcher -> matcher.group(1)); } // Protected for testing |