Author: markt Date: Mon Jun 26 12:39:15 2017 New Revision: 1799895 URL: http://svn.apache.org/viewvc?rev=1799895&view=rev Log: Refactor to reduce code duplication.
Modified: tomcat/trunk/java/org/apache/catalina/valves/RemoteAddrValve.java tomcat/trunk/java/org/apache/catalina/valves/RemoteHostValve.java tomcat/trunk/java/org/apache/catalina/valves/RequestFilterValve.java Modified: tomcat/trunk/java/org/apache/catalina/valves/RemoteAddrValve.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/RemoteAddrValve.java?rev=1799895&r1=1799894&r2=1799895&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/valves/RemoteAddrValve.java (original) +++ tomcat/trunk/java/org/apache/catalina/valves/RemoteAddrValve.java Mon Jun 26 12:39:15 2017 @@ -39,48 +39,12 @@ public final class RemoteAddrValve exten private static final Log log = LogFactory.getLog(RemoteAddrValve.class); - // ----------------------------------------------------- Instance Variables - - /** - * Flag deciding whether we add the server connector port to the property - * compared in the filtering method. The port will be appended - * using a ";" as a separator. - */ - volatile boolean addConnectorPort = false; - - // ------------------------------------------------------------- Properties - - - /** - * Get the flag deciding whether we add the server connector port to the - * property compared in the filtering method. The port will be appended - * using a ";" as a separator. - * @return <code>true</code> to add the connector port, the default is - * <code>false</code> - */ - public boolean getAddConnectorPort() { - return addConnectorPort; - } - - - /** - * Set the flag deciding whether we add the server connector port to the - * property compared in the filtering method. The port will be appended - * using a ";" as a separator. - * - * @param addConnectorPort The new flag - */ - public void setAddConnectorPort(boolean addConnectorPort) { - this.addConnectorPort = addConnectorPort; - } - - // --------------------------------------------------------- Public Methods @Override public void invoke(Request request, Response response) throws IOException, ServletException { String property; - if (addConnectorPort) { + if (getAddConnectorPort()) { property = request.getRequest().getRemoteAddr() + ";" + request.getConnector().getPort(); } else { property = request.getRequest().getRemoteAddr(); Modified: tomcat/trunk/java/org/apache/catalina/valves/RemoteHostValve.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/RemoteHostValve.java?rev=1799895&r1=1799894&r2=1799895&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/valves/RemoteHostValve.java (original) +++ tomcat/trunk/java/org/apache/catalina/valves/RemoteHostValve.java Mon Jun 26 12:39:15 2017 @@ -37,47 +37,12 @@ public final class RemoteHostValve exten private static final Log log = LogFactory.getLog(RemoteHostValve.class); - // ----------------------------------------------------- Instance Variables - - /** - * Flag deciding whether we add the server connector port to the property - * compared in the filtering method. The port will be appended - * using a ";" as a separator. - */ - volatile boolean addConnectorPort = false; - - // ------------------------------------------------------------- Properties - - - /** - * Get the flag deciding whether we add the server connector port to the - * property compared in the filtering method. The port will be appended - * using a ";" as a separator. - * @return <code>true</code> to add the connector port - */ - public boolean getAddConnectorPort() { - return addConnectorPort; - } - - - /** - * Set the flag deciding whether we add the server connector port to the - * property compared in the filtering method. The port will be appended - * using a ";" as a separator. - * - * @param addConnectorPort The new flag - */ - public void setAddConnectorPort(boolean addConnectorPort) { - this.addConnectorPort = addConnectorPort; - } - - // --------------------------------------------------------- Public Methods @Override public void invoke(Request request, Response response) throws IOException, ServletException { String property; - if (addConnectorPort) { + if (getAddConnectorPort()) { property = request.getRequest().getRemoteHost() + ";" + request.getConnector().getPort(); } else { property = request.getRequest().getRemoteHost(); Modified: tomcat/trunk/java/org/apache/catalina/valves/RequestFilterValve.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/RequestFilterValve.java?rev=1799895&r1=1799894&r2=1799895&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/valves/RequestFilterValve.java (original) +++ tomcat/trunk/java/org/apache/catalina/valves/RequestFilterValve.java Mon Jun 26 12:39:15 2017 @@ -132,6 +132,13 @@ public abstract class RequestFilterValve */ private boolean invalidAuthenticationWhenDeny = false; + /** + * Flag deciding whether we add the server connector port to the property + * compared in the filtering method. The port will be appended + * using a ";" as a separator. + */ + private volatile boolean addConnectorPort = false; + // ------------------------------------------------------------- Properties @@ -259,6 +266,28 @@ public abstract class RequestFilterValve } + /** + * Get the flag deciding whether we add the server connector port to the + * property compared in the filtering method. The port will be appended + * using a ";" as a separator. + * @return <code>true</code> to add the connector port + */ + public boolean getAddConnectorPort() { + return addConnectorPort; + } + + + /** + * Set the flag deciding whether we add the server connector port to the + * property compared in the filtering method. The port will be appended + * using a ";" as a separator. + * + * @param addConnectorPort The new flag + */ + public void setAddConnectorPort(boolean addConnectorPort) { + this.addConnectorPort = addConnectorPort; + } + // --------------------------------------------------------- Public Methods /** --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org