Polishing

This commit is contained in:
Juergen Hoeller
2017-05-02 21:38:09 +02:00
parent b709c77329
commit 7f19e57d9d
4 changed files with 41 additions and 48 deletions

View File

@@ -180,12 +180,11 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
* names. Encoding is based on the encoded-word syntax defined in RFC 2047
* and relies on {@code MimeUtility} from "javax.mail".
* <p>If not set file names will be encoded as US-ASCII.
* @param multipartCharset the charset to use
* @since 4.1.1
* @see <a href="http://en.wikipedia.org/wiki/MIME#Encoded-Word">Encoded-Word</a>
*/
public void setMultipartCharset(Charset multipartCharset) {
this.multipartCharset = multipartCharset;
public void setMultipartCharset(Charset charset) {
this.multipartCharset = charset;
}

View File

@@ -115,37 +115,16 @@ public class ServletHttpHandlerAdapter implements Servlet {
this.httpHandler.handle(httpRequest, httpResponse).subscribe(subscriber);
}
protected ServerHttpRequest createRequest(HttpServletRequest request,
AsyncContext context) throws IOException {
protected ServerHttpRequest createRequest(HttpServletRequest request, AsyncContext context) throws IOException {
return new ServletServerHttpRequest(
request, context, getDataBufferFactory(), getBufferSize());
}
protected ServerHttpResponse createResponse(HttpServletResponse response,
AsyncContext context) throws IOException {
protected ServerHttpResponse createResponse(HttpServletResponse response, AsyncContext context) throws IOException {
return new ServletServerHttpResponse(
response, context, getDataBufferFactory(), getBufferSize());
}
/**
* We cannot combine ERROR_LISTENER and HandlerResultSubscriber due to:
* https://issues.jboss.org/browse/WFLY-8515
*/
private static void runIfAsyncNotComplete(AsyncContext asyncContext, Runnable task) {
try {
if (asyncContext.getRequest().isAsyncStarted()) {
task.run();
}
}
catch (IllegalStateException ex) {
// Ignore:
// AsyncContext recycled and should not be used
// e.g. TIMEOUT_LISTENER (above) may have completed the AsyncContext
}
}
// Other Servlet methods...
@@ -168,6 +147,23 @@ public class ServletHttpHandlerAdapter implements Servlet {
}
/**
* We cannot combine ERROR_LISTENER and HandlerResultSubscriber due to:
* https://issues.jboss.org/browse/WFLY-8515
*/
private static void runIfAsyncNotComplete(AsyncContext asyncContext, Runnable task) {
try {
if (asyncContext.getRequest().isAsyncStarted()) {
task.run();
}
}
catch (IllegalStateException ex) {
// Ignore: AsyncContext recycled and should not be used
// e.g. TIMEOUT_LISTENER (above) may have completed the AsyncContext
}
}
private final static AsyncListener ERROR_LISTENER = new AsyncListener() {
@Override
@@ -193,16 +189,15 @@ public class ServletHttpHandlerAdapter implements Servlet {
}
};
private class HandlerResultSubscriber implements Subscriber<Void> {
private final AsyncContext asyncContext;
HandlerResultSubscriber(AsyncContext asyncContext) {
this.asyncContext = asyncContext;
}
@Override
public void onSubscribe(Subscription subscription) {
subscription.request(Long.MAX_VALUE);