HttpHeaders fails getAllow if set to EmptyCollection

Prior to this commit, calls to getAllow would fail is setAllow was set
to an EmptyCollection right before.

    java.lang.IllegalArgumentException: No enum constant
    org.springframework.http.HttpMethod

This commit fixes this by testing the header value for an empty value
before trying to use it to get a value from the Enum.

Issue: SPR-11917
(cherry picked from commit 9919a98)
This commit is contained in:
Juergen Hoeller
2014-07-01 11:46:53 +02:00
parent 41e78d0f50
commit 9054f4fb58
2 changed files with 16 additions and 3 deletions

View File

@@ -224,7 +224,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
*/
public Set<HttpMethod> getAllow() {
String value = getFirst(ALLOW);
if (value != null) {
if (!StringUtils.isEmpty(value)) {
List<HttpMethod> allowedMethod = new ArrayList<HttpMethod>(5);
String[] tokens = value.split(",\\s*");
for (String token : tokens) {