polishing

This commit is contained in:
Juergen Hoeller 2011-12-01 13:34:12 +00:00
parent dc41daa3db
commit f75e832e7c
2 changed files with 13 additions and 16 deletions

View File

@ -30,8 +30,6 @@ import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpHeaders;
@ -114,15 +112,15 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
}
private boolean isFormPost(HttpServletRequest request) {
return request.getContentType() != null && request.getContentType().contains(FORM_CONTENT_TYPE) &&
(METHOD_POST.equalsIgnoreCase(request.getMethod()));
return (request.getContentType() != null && request.getContentType().contains(FORM_CONTENT_TYPE) &&
METHOD_POST.equalsIgnoreCase(request.getMethod()));
}
/**
* Use {@link ServletRequest#getParameterMap()} to reconstruct the body of
* a form 'POST' providing a predictable outcome as opposed to reading
* from the body, which can fail if any other code has used ServletRequest
* to access a parameter thus causing the input stream to be "consumed".
* Use {@link javax.servlet.ServletRequest#getParameterMap()} to reconstruct the
* body of a form 'POST' providing a predictable outcome as opposed to reading
* from the body, which can fail if any other code has used ServletRequest
* to access a parameter thus causing the input stream to be "consumed".
*/
private InputStream getBodyFromServletRequestParameters(HttpServletRequest request) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();

View File

@ -49,7 +49,8 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler {
* Template method called from {@link #hasError(ClientHttpResponse)}.
* <p>The default implementation checks if the given status code is
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR CLIENT_ERROR}
* or {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR SERVER_ERROR}. Can be overridden in subclasses.
* or {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR SERVER_ERROR}.
* Can be overridden in subclasses.
* @param statusCode the HTTP status code
* @return <code>true</code> if the response has an error; <code>false</code> otherwise
*/
@ -59,11 +60,10 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler {
}
/**
* {@inheritDoc}
* <p>The default implementation throws a {@link HttpClientErrorException} if the response status code is
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}, a {@link HttpServerErrorException} if it is
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}, and a {@link RestClientException} in other
* cases.
* This default implementation throws a {@link HttpClientErrorException} if the response status code
* is {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}, a {@link HttpServerErrorException}
* if it is {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR},
* and a {@link RestClientException} in other cases.
*/
public void handleError(ClientHttpResponse response) throws IOException {
HttpStatus statusCode = response.getStatusCode();
@ -84,10 +84,9 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler {
try {
return FileCopyUtils.copyToByteArray(response.getBody());
}
catch (IOException e) {
catch (IOException ex) {
return new byte[0];
}
}
}