Browse Source

Merge pull request #22421 from olszewskimichal/LinkedMultiValueMap-OutOfBoundException-When-EmptyList

LinkedMultiValueMap.getFirst - check that values is not empty
pull/22916/head
Juergen Hoeller 6 years ago committed by GitHub
parent
commit
7e5aacf8a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      spring-core/src/main/java/org/springframework/util/LinkedMultiValueMap.java

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

@ -81,7 +81,7 @@ public class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V>, Serializa @@ -81,7 +81,7 @@ public class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V>, Serializa
@Nullable
public V getFirst(K key) {
List<V> values = this.targetMap.get(key);
return (values != null ? values.get(0) : null);
return (values != null && !values.isEmpty() ? values.get(0) : null);
}
@Override

Loading…
Cancel
Save