Remove an unnecessary intermediate variable

See gh-1650
This commit is contained in:
Johnny Lim 2018-01-24 11:09:35 +09:00 committed by Stephane Nicoll
parent 1af052433c
commit 826db88509
1 changed files with 3 additions and 4 deletions

View File

@ -327,20 +327,19 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
protected String getMessagePayload(HttpServletRequest request) {
ContentCachingRequestWrapper wrapper =
WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class);
String payload = null;
if (wrapper != null) {
byte[] buf = wrapper.getContentAsByteArray();
if (buf.length > 0) {
int length = Math.min(buf.length, getMaxPayloadLength());
try {
payload = new String(buf, 0, length, wrapper.getCharacterEncoding());
return new String(buf, 0, length, wrapper.getCharacterEncoding());
}
catch (UnsupportedEncodingException ex) {
payload = "[unknown]";
return "[unknown]";
}
}
}
return payload;
return null;
}