You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2026/10/01 16:45:25 UTC
(tomcat) branch 9.0.x updated: Wrap debug log calls.
This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new e57b9474f5 Wrap debug log calls.
e57b9474f5 is described below
commit e57b9474f5101360f88bbe67c950f565f1ac63d5
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 1 17:43:09 2026 +0100
Wrap debug log calls.
It is arguable is isn't necessary to wrap them all, but wrap them all
for consistency.
---
.../apache/catalina/filters/RemoteIpFilter.java | 38 +++++++++++++++-------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/java/org/apache/catalina/filters/RemoteIpFilter.java b/java/org/apache/catalina/filters/RemoteIpFilter.java
index 1393b18a27..10532fef7a 100644
--- a/java/org/apache/catalina/filters/RemoteIpFilter.java
+++ b/java/org/apache/catalina/filters/RemoteIpFilter.java
@@ -473,8 +473,8 @@ public class RemoteIpFilter extends GenericFilter {
private static final long serialVersionUID = 1L;
/**
- * Wrapper for {@link HttpServletRequest} that allows modification of headers, remote address,
- * scheme, and other properties used by the RemoteIpFilter.
+ * Wrapper for {@link HttpServletRequest} that allows modification of headers, remote address, scheme, and other
+ * properties used by the RemoteIpFilter.
*/
public static class XForwardedRequest extends HttpServletRequestWrapper {
@@ -566,6 +566,7 @@ public class RemoteIpFilter extends GenericFilter {
* Find the header entry for the given name (case-insensitive).
*
* @param name the header name to look up
+ *
* @return the header entry, or {@code null} if not found
*/
protected Map.Entry<String,List<String>> getHeaderEntry(String name) {
@@ -650,7 +651,7 @@ public class RemoteIpFilter extends GenericFilter {
/**
* Set a header value.
*
- * @param name the header name
+ * @param name the header name
* @param value the header value
*/
public void setHeader(String name, String value) {
@@ -923,8 +924,8 @@ public class RemoteIpFilter extends GenericFilter {
private boolean enableLookups;
/**
- * Process the incoming request, updating the remote address, scheme, and headers based on
- * the configured forwarded headers when the request comes from a trusted proxy.
+ * Process the incoming request, updating the remote address, scheme, and headers based on the configured forwarded
+ * headers when the request comes from a trusted proxy.
*
* @param request The servlet request to be processed
* @param response The servlet response to be created
@@ -990,7 +991,9 @@ public class RemoteIpFilter extends GenericFilter {
// We know we need a DNS look up so use getCanonicalHostName()
xRequest.setRemoteHost(inetAddress.getCanonicalHostName());
} catch (UnknownHostException e) {
- log.debug(sm.getString("remoteIpFilter.invalidRemoteAddress", remoteIp), e);
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("remoteIpFilter.invalidRemoteAddress", remoteIp), e);
+ }
xRequest.setRemoteHost(remoteIp);
}
} else {
@@ -1033,7 +1036,10 @@ public class RemoteIpFilter extends GenericFilter {
try {
int portIndex = Host.parse(hostHeaderValue);
if (portIndex > -1) {
- log.debug(sm.getString("remoteIpFilter.invalidHostWithPort", hostHeaderValue, hostHeader));
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("remoteIpFilter.invalidHostWithPort", hostHeaderValue,
+ hostHeader));
+ }
hostHeaderValue = hostHeaderValue.substring(0, portIndex);
}
@@ -1043,7 +1049,10 @@ public class RemoteIpFilter extends GenericFilter {
}
} catch (IllegalArgumentException iae) {
- log.debug(sm.getString("remoteIpFilter.invalidHostHeader", hostHeaderValue, hostHeader), iae);
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("remoteIpFilter.invalidHostHeader", hostHeaderValue, hostHeader),
+ iae);
+ }
}
}
}
@@ -1105,10 +1114,14 @@ public class RemoteIpFilter extends GenericFilter {
try {
port = Integer.parseInt(portHeaderValue);
} catch (NumberFormatException nfe) {
- log.debug(sm.getString("remoteIpFilter.invalidPort", portHeaderValue, getPortHeader()), nfe);
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("remoteIpFilter.invalidPort", portHeaderValue, getPortHeader()), nfe);
+ }
}
if (port < 1 || port > 65535) {
- log.debug(sm.getString("remoteIpFilter.invalidPort", portHeaderValue, getPortHeader()));
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("remoteIpFilter.invalidPort", portHeaderValue, getPortHeader()));
+ }
port = defaultPort;
}
}
@@ -1524,11 +1537,14 @@ public class RemoteIpFilter extends GenericFilter {
/**
* Restores the log after deserialization.
+ * <p>
* Log objects are not Serializable but this Filter is because it extends GenericFilter. Tomcat won't serialize a
* Filter but in case something else does...
+ *
* @param ois the object input stream
+ *
* @throws ClassNotFoundException if the class is not found
- * @throws IOException if an I/O error occurs
+ * @throws IOException if an I/O error occurs
*/
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org