Polishing

This commit is contained in:
Juergen Hoeller 2017-10-18 20:21:49 +02:00
parent c3378fda33
commit 9df6f3e6b8
5 changed files with 14 additions and 11 deletions

View File

@ -77,9 +77,10 @@ public class FormHttpMessageReader implements HttpMessageReader<MultiValueMap<St
@Override
public boolean canRead(ResolvableType elementType, @Nullable MediaType mediaType) {
return (MULTIVALUE_TYPE.isAssignableFrom(elementType) ||
(elementType.hasUnresolvableGenerics() && MultiValueMap.class.isAssignableFrom(elementType.resolve()))) &&
(mediaType == null || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType));
return ((MULTIVALUE_TYPE.isAssignableFrom(elementType) ||
(elementType.hasUnresolvableGenerics() &&
MultiValueMap.class.isAssignableFrom(elementType.resolve(Object.class)))) &&
(mediaType == null || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType)));
}
@Override

View File

@ -78,7 +78,8 @@ public class FormHttpMessageWriter implements HttpMessageWriter<MultiValueMap<St
@Override
public boolean canWrite(ResolvableType elementType, @Nullable MediaType mediaType) {
return (MULTIVALUE_TYPE.isAssignableFrom(elementType) ||
(elementType.hasUnresolvableGenerics() && MultiValueMap.class.isAssignableFrom(elementType.resolve()))) &&
(elementType.hasUnresolvableGenerics() &&
MultiValueMap.class.isAssignableFrom(elementType.resolve(Object.class)))) &&
(mediaType == null || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.http.codec;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.core.ResolvableType;
@ -30,6 +29,8 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import static org.junit.Assert.*;
/**
* @author Sebastien Deleuze
*/
@ -37,6 +38,7 @@ public class FormHttpMessageReaderTests {
private final FormHttpMessageReader reader = new FormHttpMessageReader();
@Test
public void canRead() {
assertTrue(this.reader.canRead(
@ -94,6 +96,7 @@ public class FormHttpMessageReaderTests {
assertNull("Invalid result", result.getFirst("name 3"));
}
private MockServerHttpRequest request(String body) {
return MockServerHttpRequest
.method(HttpMethod.GET, "/")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,9 +18,6 @@ package org.springframework.http.codec;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import reactor.core.publisher.Mono;
@ -30,6 +27,8 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import static org.junit.Assert.*;
/**
* @author Sebastien Deleuze
*/

View File

@ -126,7 +126,6 @@ public class ServletModelAttributeMethodProcessor extends ModelAttributeMethodPr
* @param request the current request
* @return the created model attribute, or {@code null} if no suitable
* conversion found
* @throws Exception
*/
@Nullable
protected Object createAttributeFromRequestValue(String sourceValue, String attributeName,