Skip to content

Commit 9df6f3e

Browse files
committed
Polishing
1 parent c3378fd commit 9df6f3e

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageReader.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ public Charset getDefaultCharset() {
7777

7878
@Override
7979
public boolean canRead(ResolvableType elementType, @Nullable MediaType mediaType) {
80-
return (MULTIVALUE_TYPE.isAssignableFrom(elementType) ||
81-
(elementType.hasUnresolvableGenerics() && MultiValueMap.class.isAssignableFrom(elementType.resolve()))) &&
82-
(mediaType == null || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType));
80+
return ((MULTIVALUE_TYPE.isAssignableFrom(elementType) ||
81+
(elementType.hasUnresolvableGenerics() &&
82+
MultiValueMap.class.isAssignableFrom(elementType.resolve(Object.class)))) &&
83+
(mediaType == null || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType)));
8384
}
8485

8586
@Override

spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageWriter.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public Charset getDefaultCharset() {
7878
@Override
7979
public boolean canWrite(ResolvableType elementType, @Nullable MediaType mediaType) {
8080
return (MULTIVALUE_TYPE.isAssignableFrom(elementType) ||
81-
(elementType.hasUnresolvableGenerics() && MultiValueMap.class.isAssignableFrom(elementType.resolve()))) &&
81+
(elementType.hasUnresolvableGenerics() &&
82+
MultiValueMap.class.isAssignableFrom(elementType.resolve(Object.class)))) &&
8283
(mediaType == null || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType));
8384
}
8485

spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22-
import static org.junit.Assert.*;
2322
import org.junit.Test;
2423

2524
import org.springframework.core.ResolvableType;
@@ -30,13 +29,16 @@
3029
import org.springframework.util.LinkedMultiValueMap;
3130
import org.springframework.util.MultiValueMap;
3231

32+
import static org.junit.Assert.*;
33+
3334
/**
3435
* @author Sebastien Deleuze
3536
*/
3637
public class FormHttpMessageReaderTests {
3738

3839
private final FormHttpMessageReader reader = new FormHttpMessageReader();
3940

41+
4042
@Test
4143
public void canRead() {
4244
assertTrue(this.reader.canRead(
@@ -94,6 +96,7 @@ public void readFormAsFlux() {
9496
assertNull("Invalid result", result.getFirst("name 3"));
9597
}
9698

99+
97100
private MockServerHttpRequest request(String body) {
98101
return MockServerHttpRequest
99102
.method(HttpMethod.GET, "/")

spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,9 +18,6 @@
1818

1919
import java.util.Map;
2020

21-
import static org.junit.Assert.assertEquals;
22-
import static org.junit.Assert.assertFalse;
23-
import static org.junit.Assert.assertTrue;
2421
import org.junit.Test;
2522
import reactor.core.publisher.Mono;
2623

@@ -30,6 +27,8 @@
3027
import org.springframework.util.LinkedMultiValueMap;
3128
import org.springframework.util.MultiValueMap;
3229

30+
import static org.junit.Assert.*;
31+
3332
/**
3433
* @author Sebastien Deleuze
3534
*/

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessor.java

-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ protected final Map<String, String> getUriTemplateVariables(NativeWebRequest req
126126
* @param request the current request
127127
* @return the created model attribute, or {@code null} if no suitable
128128
* conversion found
129-
* @throws Exception
130129
*/
131130
@Nullable
132131
protected Object createAttributeFromRequestValue(String sourceValue, String attributeName,

0 commit comments

Comments
 (0)