Skip to content

Commit 216be09

Browse files
authored
Refactor null key test to use variable
1 parent 90f13b3 commit 216be09

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/test/java/com/thealgorithms/datastructures/hashmap/hashing/GenericHashMapUsingArrayTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ void testContainsKey() {
9797
@Test
9898
void shouldThrowNullPointerExceptionForNullKey() {
9999
GenericHashMapUsingArray<String, String> map = new GenericHashMapUsingArray<>();
100-
Assertions.assertThrows(NullPointerException.class, () -> map.put(null, "value"));
100+
String nullKey = null; // Use variable to avoid static analysis false positive
101+
Assertions.assertThrows(NullPointerException.class, () -> map.put(nullKey, "value"));
101102
}
102103

103104
@Test

0 commit comments

Comments
 (0)