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

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-validator.git


The following commit(s) were added to refs/heads/master by this push:
     new 519c3ba4 Precompile Pattern in ISSNValidator.convertToEAN13(String, 
String).
519c3ba4 is described below

commit 519c3ba4bfd572d84af407ac4674ed1a6686b622
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Jul 26 18:41:40 2026 -0400

    Precompile Pattern in ISSNValidator.convertToEAN13(String, String).
---
 src/changes/changes.xml                                              | 1 +
 .../java/org/apache/commons/validator/routines/ISSNValidator.java    | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index cbd7d45b..96d05f60 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -111,6 +111,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary 
Gregory">Reject over-length codes in ABA, CUSIP, ISBN-10 and EAN-13 check 
digits (#427).</action>
     <action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary 
Gregory">Require the IPv6: tag for bracketed IPv6 email literals 
(#428).</action>
     <action type="fix" dev="ggregory" due-to="sahvx655-wq, Gary 
Gregory">Reject nameprep-stripped code points in unicodeToASCII (#429).</action>
+    <action type="fix" dev="ggregory" due-to="Gary Gregory">Precompile Pattern 
in ISSNValidator.convertToEAN13(String, String).</action>
     <!-- ADD -->
     <action type="add" dev="ggregory" due-to="Gary Gregory">Add and use 
CheckDigitException.CheckDigitException(String, Object...) (#389).</action>
     <action type="add" dev="ggregory" due-to="Gary Gregory">Add and use 
ValidatorException.ValidatorException(Throwable). Call sites that previously 
called new ValidatorException(Throwable#getMessage()) now preserve that 
exception (#390).</action>
diff --git 
a/src/main/java/org/apache/commons/validator/routines/ISSNValidator.java 
b/src/main/java/org/apache/commons/validator/routines/ISSNValidator.java
index 426065c8..f113d0a5 100644
--- a/src/main/java/org/apache/commons/validator/routines/ISSNValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/ISSNValidator.java
@@ -17,6 +17,7 @@
 package org.apache.commons.validator.routines;
 
 import java.io.Serializable;
+import java.util.regex.Pattern;
 
 import org.apache.commons.validator.routines.checkdigit.CheckDigitException;
 import org.apache.commons.validator.routines.checkdigit.EAN13CheckDigit;
@@ -66,6 +67,8 @@ public class ISSNValidator implements Serializable {
 
     private static final long serialVersionUID = 4319515687976420405L;
 
+    private static final Pattern DIGIT_DIGIT = Pattern.compile("\\d\\d");
+
     private static final String ISSN_REGEX = "(?:ISSN 
)?(\\d{4})-(\\d{3}[0-9X])$"; // We don't include the '-' in the code, so it is 
8 chars
 
     private static final int ISSN_LEN = 8;
@@ -114,7 +117,7 @@ public class ISSNValidator implements Serializable {
      * if the input ISSN code is not valid
      */
     public String convertToEAN13(final String issn, final String suffix) {
-        if (suffix == null || !suffix.matches("\\d\\d")) {
+        if (suffix == null || !DIGIT_DIGIT.matcher(suffix).matches()) {
             throw new IllegalArgumentException("Suffix must be two digits: '" 
+ suffix + "'");
         }
         final Object result = validate(issn);

Reply via email to