Skip to content

Commit 2a28542

Browse files
committed
2 parents ea1f847 + 88c16ac commit 2a28542

5 files changed

Lines changed: 15 additions & 12 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ The <action> type attribute can be add,update,fix,remove.
6565
<release version="1.10.2" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required.">
6666
<!-- FIX -->
6767
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Apache RAT plugin console warnings.</action>
68+
<action type="fix" dev="sebb">Fixes to non-final static fields</action>
6869
<!-- ADD -->
6970
<!-- UPDATE -->
7071
<action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump org.apache.commons:commons-parent from 92 to 93 #377.</action>

src/example/org/apache/commons/validator/example/ValidateExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class ValidateExample {
5050
* from. Note that this is not strictly required to make the Validator
5151
* work, but is a good coding practice.
5252
*/
53-
private static ResourceBundle apps =
53+
private static final ResourceBundle apps =
5454
ResourceBundle.getBundle(
5555
"org.apache.commons.validator.example.applicationResources");
5656

src/main/java/org/apache/commons/validator/ValidatorResources.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public class ValidatorResources implements Serializable {
8282
/**
8383
* The default locale on our server.
8484
*/
85-
protected static Locale defaultLocale = Locale.getDefault();
85+
@Deprecated // ought to be final, but is not used, so could be dropped
86+
protected static Locale defaultLocale = Locale.getDefault(); // NOPMD not used
8687

8788
private static final String ARGS_PATTERN
8889
= "form-validation/formset/form/field/arg";

src/main/java/org/apache/commons/validator/routines/DomainValidator.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,32 +1775,32 @@ private static class LazyHolder { // IODH
17751775
* This field does not need to be volatile since it is only accessed from
17761776
* synchronized methods.
17771777
*/
1778-
private static boolean inUse;
1778+
private static boolean inUse; //NOPMD @GuardedBy("this")
17791779
/*
17801780
* These arrays are mutable.
17811781
* They can only be updated by the updateTLDOverride method, and readers must first get an instance
17821782
* using the getInstance methods which are all (now) synchronized.
17831783
* The only other access is via getTLDEntries which is now synchronized.
17841784
*/
17851785
// WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1786-
private static String[] countryCodeTLDsPlus = EMPTY_STRING_ARRAY;
1786+
private static String[] countryCodeTLDsPlus = EMPTY_STRING_ARRAY; //NOPMD @GuardedBy("this")
17871787
// WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1788-
private static String[] genericTLDsPlus = EMPTY_STRING_ARRAY;
1788+
private static String[] genericTLDsPlus = EMPTY_STRING_ARRAY; //NOPMD @GuardedBy("this")
17891789
// WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1790-
private static String[] countryCodeTLDsMinus = EMPTY_STRING_ARRAY;
1790+
private static String[] countryCodeTLDsMinus = EMPTY_STRING_ARRAY; //NOPMD @GuardedBy("this")
17911791
// WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1792-
private static String[] genericTLDsMinus = EMPTY_STRING_ARRAY;
1792+
private static String[] genericTLDsMinus = EMPTY_STRING_ARRAY; //NOPMD @GuardedBy("this")
17931793

17941794
// The constructors are deliberately private to avoid possible problems with unsafe publication.
17951795
// It is vital that the static override arrays are not mutable once they have been used in an instance
17961796
// The arrays could be copied into the instance variables, however if the static array were changed it could
17971797
// result in different settings for the shared default instances
17981798

17991799
// WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1800-
private static String[] localTLDsMinus = EMPTY_STRING_ARRAY;
1800+
private static String[] localTLDsMinus = EMPTY_STRING_ARRAY; //NOPMD @GuardedBy("this")
18011801

18021802
// WARNING: this array MUST be sorted, otherwise it cannot be searched reliably using binary search
1803-
private static String[] localTLDsPlus = EMPTY_STRING_ARRAY;
1803+
private static String[] localTLDsPlus = EMPTY_STRING_ARRAY; //NOPMD @GuardedBy("this")
18041804

18051805
/**
18061806
* Tests if a sorted array contains the specified key

src/test/java/org/apache/commons/validator/ExtensionTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.junit.jupiter.api.Assertions.assertTrue;
2424

2525
import java.io.InputStream;
26+
import java.util.Locale;
2627

2728
import org.junit.jupiter.api.AfterEach;
2829
import org.junit.jupiter.api.BeforeEach;
@@ -81,9 +82,9 @@ protected void tearDown() {
8182
*/
8283
@Test
8384
void testOrder() {
84-
85-
final Form form = resources.getForm(ValidatorResources.defaultLocale, FORM_KEY);
86-
final Form form2 = resources.getForm(ValidatorResources.defaultLocale, FORM_KEY2);
85+
final Locale defaultLocale = Locale.getDefault();
86+
final Form form = resources.getForm(defaultLocale, FORM_KEY);
87+
final Form form2 = resources.getForm(defaultLocale, FORM_KEY2);
8788

8889
assertNotNull(form, FORM_KEY + " is null.");
8990
assertEquals(2, form.getFields().size(), "There should only be 2 fields in " + FORM_KEY);

0 commit comments

Comments
 (0)