This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 7fcb7c9dc9 Unify conditional statement format (#661)
7fcb7c9dc9 is described below

commit 7fcb7c9dc949733dd5c273a7799ca4e46968d006
Author: ReO <89302528+jaeyoun...@users.noreply.github.com>
AuthorDate: Wed Sep 6 22:13:18 2023 +0900

    Unify conditional statement format (#661)
    
    Remove unnecessary parentheses
    
    Simplify some conditional statements using De Morgan's law
---
 java/org/apache/catalina/ant/AbstractCatalinaTask.java         |  2 +-
 java/org/apache/catalina/connector/Request.java                |  4 ++--
 java/org/apache/catalina/connector/Response.java               |  2 +-
 java/org/apache/catalina/core/ApplicationContext.java          |  4 ++--
 java/org/apache/catalina/core/ApplicationFilterFactory.java    |  2 +-
 java/org/apache/catalina/core/StandardContext.java             |  2 +-
 java/org/apache/catalina/filters/CsrfPreventionFilter.java     |  2 +-
 java/org/apache/catalina/manager/ManagerServlet.java           |  2 +-
 java/org/apache/catalina/manager/host/HostManagerServlet.java  |  2 +-
 java/org/apache/catalina/realm/JNDIRealm.java                  |  2 +-
 java/org/apache/catalina/realm/RealmBase.java                  |  2 +-
 java/org/apache/coyote/ajp/AjpMessage.java                     |  2 +-
 java/org/apache/coyote/http11/Http11InputBuffer.java           | 10 +++++-----
 java/org/apache/coyote/http11/filters/ChunkedInputFilter.java  |  6 +++---
 .../apache/tomcat/util/descriptor/web/SecurityConstraint.java  |  4 ++--
 java/org/apache/tomcat/util/digester/RulesBase.java            |  2 +-
 16 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/java/org/apache/catalina/ant/AbstractCatalinaTask.java 
b/java/org/apache/catalina/ant/AbstractCatalinaTask.java
index 75676e2960..61ac76e5e5 100644
--- a/java/org/apache/catalina/ant/AbstractCatalinaTask.java
+++ b/java/org/apache/catalina/ant/AbstractCatalinaTask.java
@@ -233,7 +233,7 @@ public abstract class AbstractCatalinaTask extends 
BaseRedirectorHelperTask {
                 int ch = reader.read();
                 if (ch < 0) {
                     break;
-                } else if ((ch == '\r') || (ch == '\n')) {
+                } else if (ch == '\r' || ch == '\n') {
                     // in Win \r\n would cause handleOutput() to be called
                     // twice, the second time with an empty string,
                     // producing blank lines
diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index f95095525b..931e2f7fe1 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1573,7 +1573,7 @@ public class Request implements HttpServletRequest {
             return;
         }
         Object listeners[] = context.getApplicationEventListeners();
-        if ((listeners == null) || (listeners.length == 0)) {
+        if (listeners == null || listeners.length == 0) {
             return;
         }
         boolean replaced = (oldValue != null);
@@ -1614,7 +1614,7 @@ public class Request implements HttpServletRequest {
     private void notifyAttributeRemoved(String name, Object value) {
         Context context = getContext();
         Object listeners[] = context.getApplicationEventListeners();
-        if ((listeners == null) || (listeners.length == 0)) {
+        if (listeners == null || listeners.length == 0) {
             return;
         }
         ServletRequestAttributeEvent event =
diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index 914199321c..ddc67e955f 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -1782,7 +1782,7 @@ public class Response implements HttpServletResponse {
      * @return the encoded URL
      */
     protected String toEncoded(String url, String sessionId) {
-        if ((url == null) || (sessionId == null)) {
+        if (url == null || sessionId == null) {
             return url;
         }
 
diff --git a/java/org/apache/catalina/core/ApplicationContext.java 
b/java/org/apache/catalina/core/ApplicationContext.java
index 1e33f41dbd..af14aefd26 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -664,7 +664,7 @@ public class ApplicationContext implements ServletContext {
 
         // Notify interested application event listeners
         Object listeners[] = context.getApplicationEventListeners();
-        if ((listeners == null) || (listeners.length == 0)) {
+        if (listeners == null || listeners.length == 0) {
             return;
         }
         ServletContextAttributeEvent event = new 
ServletContextAttributeEvent(context.getServletContext(), name, value);
@@ -711,7 +711,7 @@ public class ApplicationContext implements ServletContext {
 
         // Notify interested application event listeners
         Object listeners[] = context.getApplicationEventListeners();
-        if ((listeners == null) || (listeners.length == 0)) {
+        if (listeners == null || listeners.length == 0) {
             return;
         }
         ServletContextAttributeEvent event = null;
diff --git a/java/org/apache/catalina/core/ApplicationFilterFactory.java 
b/java/org/apache/catalina/core/ApplicationFilterFactory.java
index 3c3ea43c76..ad723df92e 100644
--- a/java/org/apache/catalina/core/ApplicationFilterFactory.java
+++ b/java/org/apache/catalina/core/ApplicationFilterFactory.java
@@ -81,7 +81,7 @@ public final class ApplicationFilterFactory {
         FilterMap filterMaps[] = context.findFilterMaps();
 
         // If there are no filter mappings, we are done
-        if ((filterMaps == null) || (filterMaps.length == 0)) {
+        if (filterMaps == null || filterMaps.length == 0) {
             return filterChain;
         }
 
diff --git a/java/org/apache/catalina/core/StandardContext.java 
b/java/org/apache/catalina/core/StandardContext.java
index d1bcbead6c..9547768514 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -2923,7 +2923,7 @@ public class StandardContext extends ContainerBase 
implements Context, Notificat
     @Override
     public void addParameter(String name, String value) {
         // Validate the proposed context initialization parameter
-        if ((name == null) || (value == null)) {
+        if (name == null || value == null) {
             throw new 
IllegalArgumentException(sm.getString("standardContext.parameter.required"));
         }
 
diff --git a/java/org/apache/catalina/filters/CsrfPreventionFilter.java 
b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
index ef5e979126..2464ebc59c 100644
--- a/java/org/apache/catalina/filters/CsrfPreventionFilter.java
+++ b/java/org/apache/catalina/filters/CsrfPreventionFilter.java
@@ -303,7 +303,7 @@ public class CsrfPreventionFilter extends 
CsrfPreventionFilterBase {
          */
         private String addNonce(String url) {
 
-            if ((url == null) || (nonce == null)) {
+            if (url == null || nonce == null) {
                 return url;
             }
 
diff --git a/java/org/apache/catalina/manager/ManagerServlet.java 
b/java/org/apache/catalina/manager/ManagerServlet.java
index fcaeaba66e..08c239cd5d 100644
--- a/java/org/apache/catalina/manager/ManagerServlet.java
+++ b/java/org/apache/catalina/manager/ManagerServlet.java
@@ -468,7 +468,7 @@ public class ManagerServlet extends HttpServlet implements 
ContainerServlet {
     public void init() throws ServletException {
 
         // Ensure that our ContainerServlet properties have been set
-        if ((wrapper == null) || (context == null)) {
+        if (wrapper == null || context == null) {
             throw new UnavailableException(
                     sm.getString("managerServlet.noWrapper"));
         }
diff --git a/java/org/apache/catalina/manager/host/HostManagerServlet.java 
b/java/org/apache/catalina/manager/host/HostManagerServlet.java
index c488f5a2b5..956091e555 100644
--- a/java/org/apache/catalina/manager/host/HostManagerServlet.java
+++ b/java/org/apache/catalina/manager/host/HostManagerServlet.java
@@ -302,7 +302,7 @@ public class HostManagerServlet
     public void init() throws ServletException {
 
         // Ensure that our ContainerServlet properties have been set
-        if ((wrapper == null) || (context == null)) {
+        if (wrapper == null || context == null) {
             throw new UnavailableException
                 (sm.getString("hostManagerServlet.noWrapper"));
         }
diff --git a/java/org/apache/catalina/realm/JNDIRealm.java 
b/java/org/apache/catalina/realm/JNDIRealm.java
index c55f075779..04fceead64 100644
--- a/java/org/apache/catalina/realm/JNDIRealm.java
+++ b/java/org/apache/catalina/realm/JNDIRealm.java
@@ -1952,7 +1952,7 @@ public class JNDIRealm extends RealmBase {
         }
 
         // Are we configured to do role searches?
-        if ((connection.roleFormat == null) || (roleName == null)) {
+        if (connection.roleFormat == null || roleName == null) {
             return list;
         }
 
diff --git a/java/org/apache/catalina/realm/RealmBase.java 
b/java/org/apache/catalina/realm/RealmBase.java
index 997bd28b2f..9d7e9a760b 100644
--- a/java/org/apache/catalina/realm/RealmBase.java
+++ b/java/org/apache/catalina/realm/RealmBase.java
@@ -532,7 +532,7 @@ public abstract class RealmBase extends LifecycleMBeanBase 
implements org.apache
         ArrayList<SecurityConstraint> results = null;
         // Are there any defined security constraints?
         SecurityConstraint constraints[] = context.findConstraints();
-        if ((constraints == null) || (constraints.length == 0)) {
+        if (constraints == null || constraints.length == 0) {
             if (log.isDebugEnabled()) {
                 log.debug("  No applicable constraints defined");
             }
diff --git a/java/org/apache/coyote/ajp/AjpMessage.java 
b/java/org/apache/coyote/ajp/AjpMessage.java
index 53fca56514..1e4f0c6f3e 100644
--- a/java/org/apache/coyote/ajp/AjpMessage.java
+++ b/java/org/apache/coyote/ajp/AjpMessage.java
@@ -289,7 +289,7 @@ public class AjpMessage {
 
     private void doGetBytes(MessageBytes mb, boolean terminated) {
         int length = getInt();
-        if ((length == 0xFFFF) || (length == -1)) {
+        if (length == 0xFFFF || length == -1) {
             mb.recycle();
             return;
         }
diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java 
b/java/org/apache/coyote/http11/Http11InputBuffer.java
index 87799b7d6c..002b304ccf 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -388,7 +388,7 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
                     request.setStartTime(System.currentTimeMillis());
                 }
                 chr = byteBuffer.get();
-            } while ((chr == Constants.CR) || (chr == Constants.LF));
+            } while (chr == Constants.CR || chr == Constants.LF);
             byteBuffer.position(byteBuffer.position() - 1);
 
             parsingRequestLineStart = byteBuffer.position();
@@ -435,7 +435,7 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
                     }
                 }
                 chr = byteBuffer.get();
-                if (!(chr == Constants.SP || chr == Constants.HT)) {
+                if (chr != Constants.SP && chr != Constants.HT) {
                     space = false;
                     byteBuffer.position(byteBuffer.position() - 1);
                 }
@@ -531,7 +531,7 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
                     }
                 }
                 byte chr = byteBuffer.get();
-                if (!(chr == Constants.SP || chr == Constants.HT)) {
+                if (chr != Constants.SP && chr != Constants.HT) {
                     space = false;
                     byteBuffer.position(byteBuffer.position() - 1);
                 }
@@ -936,7 +936,7 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
                     }
 
                     chr = byteBuffer.get();
-                    if (!(chr == Constants.SP || chr == Constants.HT)) {
+                    if (chr != Constants.SP && chr != Constants.HT) {
                         headerParsePos = HeaderParsePosition.HEADER_VALUE;
                         byteBuffer.position(byteBuffer.position() - 1);
                         // Avoids prevChr = chr at start of header value
@@ -1002,7 +1002,7 @@ public class Http11InputBuffer implements InputBuffer, 
ApplicationBufferHandler
 
             byte peek = byteBuffer.get(byteBuffer.position());
             if (headerParsePos == HeaderParsePosition.HEADER_MULTI_LINE) {
-                if ((peek != Constants.SP) && (peek != Constants.HT)) {
+                if (peek != Constants.SP && peek != Constants.HT) {
                     headerParsePos = HeaderParsePosition.HEADER_START;
                     break;
                 } else {
diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 
b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
index a614f96b57..c8349923cb 100644
--- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
+++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
@@ -544,7 +544,7 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
 
             // readBytes() above will set readChunk unless it returns a value 
< 0
             chr = readChunk.get(readChunk.position());
-            if ((chr >= Constants.A) && (chr <= Constants.Z)) {
+            if (chr >= Constants.A && chr <= Constants.Z) {
                 chr = (byte) (chr - Constants.LC_OFFSET);
             }
 
@@ -582,7 +582,7 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
                 }
 
                 chr = readChunk.get(readChunk.position());
-                if ((chr == Constants.SP) || (chr == Constants.HT)) {
+                if (chr == Constants.SP || chr == Constants.HT) {
                     readChunk.position(readChunk.position() + 1);
                     // If we swallow whitespace, make sure it counts towards 
the
                     // limit placed on trailing header size
@@ -634,7 +634,7 @@ public class ChunkedInputFilter implements InputFilter, 
ApplicationBufferHandler
             }
 
             chr = readChunk.get(readChunk.position());
-            if ((chr != Constants.SP) && (chr != Constants.HT)) {
+            if (chr != Constants.SP && chr != Constants.HT) {
                 validLine = false;
             } else {
                 eol = false;
diff --git a/java/org/apache/tomcat/util/descriptor/web/SecurityConstraint.java 
b/java/org/apache/tomcat/util/descriptor/web/SecurityConstraint.java
index 8446b10605..5c210f2711 100644
--- a/java/org/apache/tomcat/util/descriptor/web/SecurityConstraint.java
+++ b/java/org/apache/tomcat/util/descriptor/web/SecurityConstraint.java
@@ -513,10 +513,10 @@ public class SecurityConstraint extends XmlEncodingBase 
implements Serializable
     private boolean matchPattern(String path, String pattern) {
 
         // Normalize the argument strings
-        if ((path == null) || (path.length() == 0)) {
+        if (path == null || path.length() == 0) {
             path = "/";
         }
-        if ((pattern == null) || (pattern.length() == 0)) {
+        if (pattern == null || pattern.length() == 0) {
             pattern = "/";
         }
 
diff --git a/java/org/apache/tomcat/util/digester/RulesBase.java 
b/java/org/apache/tomcat/util/digester/RulesBase.java
index 7e36769b71..480eb50e76 100644
--- a/java/org/apache/tomcat/util/digester/RulesBase.java
+++ b/java/org/apache/tomcat/util/digester/RulesBase.java
@@ -250,7 +250,7 @@ public class RulesBase implements Rules {
         if (list == null) {
             return null;
         }
-        if ((namespaceURI == null) || (namespaceURI.length() == 0)) {
+        if (namespaceURI == null || namespaceURI.length() == 0) {
             return list;
         }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to