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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new b844452b53 Add a static parse() method for NetMaskSet
b844452b53 is described below

commit b844452b5367884dc2629b2303247f0d4d21fcca
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Oct 1 12:58:40 2025 +0100

    Add a static parse() method for NetMaskSet
---
 java/org/apache/catalina/util/LocalStrings.properties |  2 ++
 java/org/apache/catalina/util/NetMaskSet.java         | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/java/org/apache/catalina/util/LocalStrings.properties 
b/java/org/apache/catalina/util/LocalStrings.properties
index e1d244dbd9..a23c8b74f6 100644
--- a/java/org/apache/catalina/util/LocalStrings.properties
+++ b/java/org/apache/catalina/util/LocalStrings.properties
@@ -42,6 +42,8 @@ netmask.cidrTooBig=The CIDR [{0}] is greater than the address 
length [{1}]
 netmask.invalidAddress=The address [{0}] is not valid
 netmask.invalidPort=The port part in the pattern [{0}] is not valid
 
+netmaskSet.invalidNetMask=One or more netmasks provided are invalid: {0}
+
 parameterMap.locked=No modifications are allowed to a locked ParameterMap
 
 resourceSet.locked=No modifications are allowed to a locked ResourceSet
diff --git a/java/org/apache/catalina/util/NetMaskSet.java 
b/java/org/apache/catalina/util/NetMaskSet.java
index 6365dc8f85..38f3abeb89 100644
--- a/java/org/apache/catalina/util/NetMaskSet.java
+++ b/java/org/apache/catalina/util/NetMaskSet.java
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.tomcat.util.buf.StringUtils;
+import org.apache.tomcat.util.res.StringManager;
 
 
 /**
@@ -34,6 +35,8 @@ import org.apache.tomcat.util.buf.StringUtils;
  */
 public class NetMaskSet {
 
+    private static final StringManager sm = 
StringManager.getManager(NetMaskSet.class);
+
     private final Set<NetMask> netmasks = new HashSet<>();
 
     /**
@@ -159,4 +162,19 @@ public class NetMaskSet {
         return result;
     }
 
+
+    public static NetMaskSet parse(String input) {
+        NetMaskSet result = new NetMaskSet();
+
+        List<String> errors = result.addAll(input);
+        if (!errors.isEmpty()) {
+            StringBuilder sb = new StringBuilder();
+            for (String error : errors) {
+                sb.append(error).append("; ");
+            }
+            throw new 
IllegalArgumentException(sm.getString("netmaskSet.invalidNetMask", 
sb.toString()));
+        }
+
+        return result;
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to