Skip to content

Commit 7f19e57

Browse files
committed
Polishing
1 parent b709c77 commit 7f19e57

File tree

4 files changed

+41
-48
lines changed

4 files changed

+41
-48
lines changed

spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,11 @@ private void applyDefaultCharset() {
180180
* names. Encoding is based on the encoded-word syntax defined in RFC 2047
181181
* and relies on {@code MimeUtility} from "javax.mail".
182182
* <p>If not set file names will be encoded as US-ASCII.
183-
* @param multipartCharset the charset to use
184183
* @since 4.1.1
185184
* @see <a href="http://en.wikipedia.org/wiki/MIME#Encoded-Word">Encoded-Word</a>
186185
*/
187-
public void setMultipartCharset(Charset multipartCharset) {
188-
this.multipartCharset = multipartCharset;
186+
public void setMultipartCharset(Charset charset) {
187+
this.multipartCharset = charset;
189188
}
190189

191190

spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -115,37 +115,16 @@ public void service(ServletRequest request, ServletResponse response) throws IOE
115115
this.httpHandler.handle(httpRequest, httpResponse).subscribe(subscriber);
116116
}
117117

118-
protected ServerHttpRequest createRequest(HttpServletRequest request,
119-
AsyncContext context) throws IOException {
120-
118+
protected ServerHttpRequest createRequest(HttpServletRequest request, AsyncContext context) throws IOException {
121119
return new ServletServerHttpRequest(
122120
request, context, getDataBufferFactory(), getBufferSize());
123121
}
124122

125-
protected ServerHttpResponse createResponse(HttpServletResponse response,
126-
AsyncContext context) throws IOException {
127-
123+
protected ServerHttpResponse createResponse(HttpServletResponse response, AsyncContext context) throws IOException {
128124
return new ServletServerHttpResponse(
129125
response, context, getDataBufferFactory(), getBufferSize());
130126
}
131127

132-
/**
133-
* We cannot combine ERROR_LISTENER and HandlerResultSubscriber due to:
134-
* https://issues.jboss.org/browse/WFLY-8515
135-
*/
136-
private static void runIfAsyncNotComplete(AsyncContext asyncContext, Runnable task) {
137-
try {
138-
if (asyncContext.getRequest().isAsyncStarted()) {
139-
task.run();
140-
}
141-
}
142-
catch (IllegalStateException ex) {
143-
// Ignore:
144-
// AsyncContext recycled and should not be used
145-
// e.g. TIMEOUT_LISTENER (above) may have completed the AsyncContext
146-
}
147-
}
148-
149128

150129
// Other Servlet methods...
151130

@@ -168,6 +147,23 @@ public void destroy() {
168147
}
169148

170149

150+
/**
151+
* We cannot combine ERROR_LISTENER and HandlerResultSubscriber due to:
152+
* https://issues.jboss.org/browse/WFLY-8515
153+
*/
154+
private static void runIfAsyncNotComplete(AsyncContext asyncContext, Runnable task) {
155+
try {
156+
if (asyncContext.getRequest().isAsyncStarted()) {
157+
task.run();
158+
}
159+
}
160+
catch (IllegalStateException ex) {
161+
// Ignore: AsyncContext recycled and should not be used
162+
// e.g. TIMEOUT_LISTENER (above) may have completed the AsyncContext
163+
}
164+
}
165+
166+
171167
private final static AsyncListener ERROR_LISTENER = new AsyncListener() {
172168

173169
@Override
@@ -193,16 +189,15 @@ public void onComplete(AsyncEvent event) throws IOException {
193189
}
194190
};
195191

192+
196193
private class HandlerResultSubscriber implements Subscriber<Void> {
197194

198195
private final AsyncContext asyncContext;
199196

200-
201197
HandlerResultSubscriber(AsyncContext asyncContext) {
202198
this.asyncContext = asyncContext;
203199
}
204200

205-
206201
@Override
207202
public void onSubscribe(Subscription subscription) {
208203
subscription.request(Long.MAX_VALUE);

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@
2121
import java.util.List;
2222
import java.util.Map;
2323

24-
import static org.junit.Assert.*;
25-
import static org.junit.Assert.assertEquals;
26-
import static org.junit.Assert.assertTrue;
2724
import org.junit.Test;
28-
29-
import static org.springframework.core.ResolvableType.forClassWithGenerics;
30-
import static org.springframework.http.HttpHeaders.CONTENT_TYPE;
3125
import reactor.core.publisher.Mono;
3226

3327
import org.springframework.core.ResolvableType;
@@ -45,29 +39,34 @@
4539
import org.springframework.util.LinkedMultiValueMap;
4640
import org.springframework.util.MultiValueMap;
4741

42+
import static org.junit.Assert.*;
43+
4844
/**
4945
* @author Sebastien Deleuze
5046
*/
5147
public class MultipartHttpMessageWriterTests {
5248

53-
private final MultipartHttpMessageWriter writer = new MultipartHttpMessageWriter(
54-
Arrays.asList(
55-
new EncoderHttpMessageWriter<>(CharSequenceEncoder.textPlainOnly()),
56-
new ResourceHttpMessageWriter(),
57-
new EncoderHttpMessageWriter<>(new Jackson2JsonEncoder())
49+
private final MultipartHttpMessageWriter writer = new MultipartHttpMessageWriter(Arrays.asList(
50+
new EncoderHttpMessageWriter<>(CharSequenceEncoder.textPlainOnly()),
51+
new ResourceHttpMessageWriter(),
52+
new EncoderHttpMessageWriter<>(new Jackson2JsonEncoder())
5853
));
5954

55+
6056
@Test
6157
public void canWrite() {
62-
63-
assertTrue(this.writer.canWrite(forClassWithGenerics(MultiValueMap.class, String.class, Object.class),
58+
assertTrue(this.writer.canWrite(
59+
ResolvableType.forClassWithGenerics(MultiValueMap.class, String.class, Object.class),
6460
MediaType.MULTIPART_FORM_DATA));
65-
assertTrue(this.writer.canWrite(forClassWithGenerics(MultiValueMap.class, String.class, String.class),
61+
assertTrue(this.writer.canWrite(
62+
ResolvableType.forClassWithGenerics(MultiValueMap.class, String.class, String.class),
6663
MediaType.MULTIPART_FORM_DATA));
6764

68-
assertFalse(this.writer.canWrite(forClassWithGenerics(Map.class, String.class, Object.class),
65+
assertFalse(this.writer.canWrite(
66+
ResolvableType.forClassWithGenerics(Map.class, String.class, Object.class),
6967
MediaType.MULTIPART_FORM_DATA));
70-
assertFalse(this.writer.canWrite(forClassWithGenerics(MultiValueMap.class, String.class, Object.class),
68+
assertFalse(this.writer.canWrite(
69+
ResolvableType.forClassWithGenerics(MultiValueMap.class, String.class, Object.class),
7170
MediaType.APPLICATION_FORM_URLENCODED));
7271
}
7372

@@ -105,14 +104,13 @@ public String getFilename() {
105104
// see if Synchronoss NIO Multipart can read what we wrote
106105
SynchronossMultipartHttpMessageReader reader = new SynchronossMultipartHttpMessageReader();
107106
MockServerHttpRequest request = MockServerHttpRequest.post("/foo")
108-
.header(CONTENT_TYPE, contentType.toString())
107+
.header(HttpHeaders.CONTENT_TYPE, contentType.toString())
109108
.body(response.getBody());
110109

111-
ResolvableType elementType = forClassWithGenerics(MultiValueMap.class, String.class, Part.class);
110+
ResolvableType elementType = ResolvableType.forClassWithGenerics(MultiValueMap.class, String.class, Part.class);
112111
MultiValueMap<String, Part> requestParts = reader.readMono(elementType, request, hints).block();
113112
assertEquals(5, requestParts.size());
114113

115-
116114
Part part = requestParts.getFirst("name 1");
117115
assertEquals("name 1", part.getName());
118116
assertEquals("value 1", part.getContentAsString().block());
@@ -147,6 +145,7 @@ public String getFilename() {
147145
assertEquals("{\"bar\":\"bar\"}", part.getContentAsString().block());
148146
}
149147

148+
150149
private class Foo {
151150

152151
private String bar;

spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@
7575

7676
/**
7777
* Unit tests for {@link WebFluxConfigurationSupport}.
78+
*
7879
* @author Rossen Stoyanchev
7980
*/
8081
public class WebFluxConfigurationSupportTests {
8182

82-
8383
@Test
8484
public void requestMappingHandlerMapping() throws Exception {
8585
ApplicationContext context = loadConfig(WebFluxConfig.class);

0 commit comments

Comments
 (0)