Apply LogFormatUtils in more places
This commit is contained in:
@@ -29,6 +29,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.core.log.LogFormatUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
@@ -293,7 +294,8 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
|
||||
|
||||
protected void handleInvalidUpgradeHeader(ServerHttpRequest request, ServerHttpResponse response) throws IOException {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error("Handshake failed due to invalid Upgrade header: " + request.getHeaders().getUpgrade());
|
||||
logger.error(LogFormatUtils.formatValue(
|
||||
"Handshake failed due to invalid Upgrade header: " + request.getHeaders().getUpgrade(), -1, true));
|
||||
}
|
||||
response.setStatusCode(HttpStatus.BAD_REQUEST);
|
||||
response.getBody().write("Can \"Upgrade\" only to \"WebSocket\".".getBytes(StandardCharsets.UTF_8));
|
||||
@@ -301,7 +303,8 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
|
||||
|
||||
protected void handleInvalidConnectHeader(ServerHttpRequest request, ServerHttpResponse response) throws IOException {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error("Handshake failed due to invalid Connection header " + request.getHeaders().getConnection());
|
||||
logger.error(LogFormatUtils.formatValue(
|
||||
"Handshake failed due to invalid Connection header" + request.getHeaders().getConnection(), -1, true));
|
||||
}
|
||||
response.setStatusCode(HttpStatus.BAD_REQUEST);
|
||||
response.getBody().write("\"Connection\" must be \"upgrade\".".getBytes(StandardCharsets.UTF_8));
|
||||
@@ -325,8 +328,9 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
|
||||
protected void handleWebSocketVersionNotSupported(ServerHttpRequest request, ServerHttpResponse response) {
|
||||
if (logger.isErrorEnabled()) {
|
||||
String version = request.getHeaders().getFirst("Sec-WebSocket-Version");
|
||||
logger.error("Handshake failed due to unsupported WebSocket version: " + version +
|
||||
". Supported versions: " + Arrays.toString(getSupportedVersions()));
|
||||
logger.error(LogFormatUtils.formatValue(
|
||||
"Handshake failed due to unsupported WebSocket version: " + version +
|
||||
". Supported versions: " + Arrays.toString(getSupportedVersions()), -1, true));
|
||||
}
|
||||
response.setStatusCode(HttpStatus.UPGRADE_REQUIRED);
|
||||
response.getHeaders().set(WebSocketHttpHeaders.SEC_WEBSOCKET_VERSION,
|
||||
|
||||
@@ -34,6 +34,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.log.LogFormatUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -340,7 +341,8 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
|
||||
|
||||
if (sockJsPath == null) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Expected SockJS path. Failing request: " + request.getURI());
|
||||
logger.warn(LogFormatUtils.formatValue(
|
||||
"Expected SockJS path. Failing request: " + request.getURI(), -1, true));
|
||||
}
|
||||
response.setStatusCode(HttpStatus.NOT_FOUND);
|
||||
return;
|
||||
@@ -405,7 +407,8 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
|
||||
String[] pathSegments = StringUtils.tokenizeToStringArray(sockJsPath.substring(1), "/");
|
||||
if (pathSegments.length != 3) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Invalid SockJS path '" + sockJsPath + "' - required to have 3 path segments");
|
||||
logger.warn(LogFormatUtils.formatValue("Invalid SockJS path '" + sockJsPath + "' - " +
|
||||
"required to have 3 path segments", -1, true));
|
||||
}
|
||||
if (requestInfo != null) {
|
||||
logger.debug("Ignoring transport request: " + requestInfo);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.core.log.LogFormatUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
@@ -234,7 +235,7 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
|
||||
TransportType transportType = TransportType.fromValue(transport);
|
||||
if (transportType == null) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Unknown transport type for " + request.getURI());
|
||||
logger.warn(LogFormatUtils.formatValue("Unknown transport type for " + request.getURI(), -1, true));
|
||||
}
|
||||
response.setStatusCode(HttpStatus.NOT_FOUND);
|
||||
return;
|
||||
@@ -243,7 +244,7 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
|
||||
TransportHandler transportHandler = this.handlers.get(transportType);
|
||||
if (transportHandler == null) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("No TransportHandler for " + request.getURI());
|
||||
logger.warn(LogFormatUtils.formatValue("No TransportHandler for " + request.getURI(), -1, true));
|
||||
}
|
||||
response.setStatusCode(HttpStatus.NOT_FOUND);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user