You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2020/06/21 16:21:41 UTC
[commons-validator] branch master updated: VALIDATOR-468
DomainValidator.getTLDArray does not synch mutable arrays
This is an automated email from the ASF dual-hosted git repository.
sebb 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 8a0b8b3 VALIDATOR-468 DomainValidator.getTLDArray does not synch mutable arrays
8a0b8b3 is described below
commit 8a0b8b3f4e919684ea35b31f5d1a927d33648cf2
Author: Sebb <se...@apache.org>
AuthorDate: Sun Jun 21 17:21:32 2020 +0100
VALIDATOR-468 DomainValidator.getTLDArray does not synch mutable arrays
---
src/changes/changes.xml | 3 +++
.../commons/validator/routines/DomainValidator.java | 15 ++++++++-------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a999caa..a16a639 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -149,6 +149,9 @@ http://commons.apache.org/validator/dependencies.html
<action issue="VALIDATOR-302" type="fix" dev="sebb" due-to="Guido Zockoll">
EMailValidator: Addresses with leading spaces must not be accepted
</action>
+ <action issue="VALIDATOR-468" type="fix" dev="sebb">
+ DomainValidator.getTLDArray does not synch mutable arrays
+ </action>
</release>
<release version="1.6" date="2017-02-21" description="
diff --git a/src/main/java/org/apache/commons/validator/routines/DomainValidator.java b/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
index 4dc31f3..4034c18 100644
--- a/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/DomainValidator.java
@@ -1889,21 +1889,22 @@ public class DomainValidator implements Serializable {
private static boolean inUse = false;
/*
- * These arrays are mutable, but they don't need to be volatile.
- * They can only be updated by the updateTLDOverride method, and any readers must get an instance
+ * These arrays are mutable.
+ * They can only be updated by the updateTLDOverride method, and readers must first get an instance
* using the getInstance methods which are all (now) synchronised.
+ * The only other access is via getTLDEntries which is now synchronised.
*/
// WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
- private static volatile String[] countryCodeTLDsPlus = EMPTY_STRING_ARRAY;
+ private static String[] countryCodeTLDsPlus = EMPTY_STRING_ARRAY;
// WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
- private static volatile String[] genericTLDsPlus = EMPTY_STRING_ARRAY;
+ private static String[] genericTLDsPlus = EMPTY_STRING_ARRAY;
// WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
- private static volatile String[] countryCodeTLDsMinus = EMPTY_STRING_ARRAY;
+ private static String[] countryCodeTLDsMinus = EMPTY_STRING_ARRAY;
// WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
- private static volatile String[] genericTLDsMinus = EMPTY_STRING_ARRAY;
+ private static String[] genericTLDsMinus = EMPTY_STRING_ARRAY;
/**
* enum used by {@link DomainValidator#updateTLDOverride(ArrayType, String[])}
@@ -2002,7 +2003,7 @@ public class DomainValidator implements Serializable {
* @throws IllegalArgumentException if the table type is unexpected (should not happen)
* @since 1.5.1
*/
- public static String [] getTLDEntries(ArrayType table) {
+ public static synchronized String [] getTLDEntries(ArrayType table) {
final String array[];
switch(table) {
case COUNTRY_CODE_MINUS: