diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ParamsRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ParamsRequestCondition.java index 590c71daa7df..0b04c6f82c9a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ParamsRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ParamsRequestCondition.java @@ -137,13 +137,9 @@ public int compareTo(ParamsRequestCondition other, HttpServletRequest request) { } private long getValueMatchCount(Set expressions) { - long count = 0; - for (ParamExpression e : expressions) { - if (e.getValue() != null && !e.isNegated()) { - count++; - } - } - return count; + return expressions.stream() + .filter(e -> e.getValue() != null && !e.isNegated()) + .count(); }