This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-validator.git
commit 4955aa62ddb6b0f65607edd2e50ee57c40d71247 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Thu Sep 19 08:22:45 2024 -0400 InetAddressValidator does not need its instance variable, so uses a touch less memory --- src/changes/changes.xml | 3 ++- .../apache/commons/validator/routines/InetAddressValidator.java | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index a5bd00ec..50e201fd 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -64,7 +64,8 @@ The <action> type attribute can be add,update,fix,remove. <body> <release version="1.10.0" date="YYYY-MM-DD" description="This is a maintenance and bug fix release; requires Java 8."> <!-- FIX --> - <action type="update" dev="ggregory" due-to="Johannes Weberhofer">Fix order of actual and expected parameters in assertEquals() #246.</action> + <action type="update" dev="ggregory" due-to="Johannes Weberhofer">Fix order of actual and expected parameters in assertEquals() #246.</action> + <action type="update" dev="ggregory" due-to="Johannes Weberhofer">InetAddressValidator does not need its instance variable, so uses a touch less memory.</action> <!-- ADD --> <action type="update" dev="ggregory" due-to="Leonard Wicke, Gary Gregory">Add IBANValidator.Validator.getIbanLength().</action> <!-- UPDATE --> diff --git a/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java b/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java index b0a22da6..07d90038 100644 --- a/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java +++ b/src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java @@ -65,6 +65,9 @@ public class InetAddressValidator implements Serializable { private static final Pattern ID_CHECK_PATTERN = Pattern.compile("[^\\s/%]+"); + /** IPv4 RegexValidator */ + private final static RegexValidator IPV4_VALIDATOR = new RegexValidator(IPV4_REGEX); + /** * Returns the singleton instance of this validator. * @@ -74,9 +77,6 @@ public class InetAddressValidator implements Serializable { return VALIDATOR; } - /** IPv4 RegexValidator */ - private final RegexValidator ipv4Validator = new RegexValidator(IPV4_REGEX); - /** * Checks if the specified string is a valid IPv4 or IPv6 address. * @@ -95,7 +95,7 @@ public class InetAddressValidator implements Serializable { */ public boolean isValidInet4Address(final String inet4Address) { // verify that address conforms to generic IPv4 format - final String[] groups = ipv4Validator.match(inet4Address); + final String[] groups = IPV4_VALIDATOR.match(inet4Address); if (groups == null) { return false; }