garydgregory commented on code in PR #639:
URL: 
https://github.com/apache/commons-configuration/pull/639#discussion_r3281005869


##########
src/test/java/org/apache/commons/configuration2/io/TestCombinedLocationStrategy.java:
##########
@@ -123,6 +124,27 @@ void testInitCollectionWithNullEntries() {
         assertThrows(IllegalArgumentException.class, () -> new 
CombinedLocationStrategy(col));
     }
 
+    /**
+     * Tests that the constructor handles collections that throw NPE on 
contains(null) (like ImmutableList).
+     */
+    @Test
+    void testInitCollectionThrowsNPEOnContainsNull() {
+        // Create a collection that throws NPE on contains(null) like 
ImmutableList does
+        final Collection<FileLocationStrategy> collectionThatThrowsNPE = new 
ArrayList<FileLocationStrategy>(Arrays.asList(getSubStrategies())) {
+            @Override
+            public boolean contains(Object o) {
+                if (o == null) {

Review Comment:
   This is a test, use `assertNotNull()`.



##########
src/test/java/org/apache/commons/configuration2/io/TestCombinedLocationStrategy.java:
##########
@@ -123,6 +124,27 @@ void testInitCollectionWithNullEntries() {
         assertThrows(IllegalArgumentException.class, () -> new 
CombinedLocationStrategy(col));
     }
 
+    /**
+     * Tests that the constructor handles collections that throw NPE on 
contains(null) (like ImmutableList).
+     */
+    @Test
+    void testInitCollectionThrowsNPEOnContainsNull() {
+        // Create a collection that throws NPE on contains(null) like 
ImmutableList does
+        final Collection<FileLocationStrategy> collectionThatThrowsNPE = new 
ArrayList<FileLocationStrategy>(Arrays.asList(getSubStrategies())) {
+            @Override
+            public boolean contains(Object o) {
+                if (o == null) {
+                    throw new NullPointerException("Collection does not 
support null");

Review Comment:
   Use `Objects.requireNonNull()`.



##########
src/test/java/org/apache/commons/configuration2/io/TestCombinedLocationStrategy.java:
##########
@@ -123,6 +124,27 @@ void testInitCollectionWithNullEntries() {
         assertThrows(IllegalArgumentException.class, () -> new 
CombinedLocationStrategy(col));
     }
 
+    /**
+     * Tests that the constructor handles collections that throw NPE on 
contains(null) (like ImmutableList).
+     */
+    @Test
+    void testInitCollectionThrowsNPEOnContainsNull() {
+        // Create a collection that throws NPE on contains(null) like 
ImmutableList does
+        final Collection<FileLocationStrategy> collectionThatThrowsNPE = new 
ArrayList<FileLocationStrategy>(Arrays.asList(getSubStrategies())) {
+            @Override
+            public boolean contains(Object o) {

Review Comment:
   Use `final`.



##########
src/test/java/org/apache/commons/configuration2/io/TestCombinedLocationStrategy.java:
##########
@@ -123,6 +124,27 @@ void testInitCollectionWithNullEntries() {
         assertThrows(IllegalArgumentException.class, () -> new 
CombinedLocationStrategy(col));
     }
 
+    /**
+     * Tests that the constructor handles collections that throw NPE on 
contains(null) (like ImmutableList).
+     */
+    @Test
+    void testInitCollectionThrowsNPEOnContainsNull() {
+        // Create a collection that throws NPE on contains(null) like 
ImmutableList does

Review Comment:
   Whose `ImmutableList`? Don't you mean implementations like 
`java.util.ImmutableCollections.List12.indexOf(Object)`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to