Skip to content

Commit 7e5aacf

Browse files
authored
Merge pull request #22421 from olszewskimichal/LinkedMultiValueMap-OutOfBoundException-When-EmptyList
LinkedMultiValueMap.getFirst - check that values is not empty
2 parents 8eb9782 + 60a7909 commit 7e5aacf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

spring-core/src/main/java/org/springframework/util/LinkedMultiValueMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public LinkedMultiValueMap(Map<K, List<V>> otherMap) {
8181
@Nullable
8282
public V getFirst(K key) {
8383
List<V> values = this.targetMap.get(key);
84-
return (values != null ? values.get(0) : null);
84+
return (values != null && !values.isEmpty() ? values.get(0) : null);
8585
}
8686

8787
@Override

0 commit comments

Comments
 (0)