From 70506bb040e5e06085a9a2f3324e92cc0eb35332 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Mon, 10 Oct 2022 22:16:53 -0400 Subject: [PATCH] index null validation --- .../java/com/inteligr8/maven/aps/modeling/util/Index.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/util/Index.java b/src/main/java/com/inteligr8/maven/aps/modeling/util/Index.java index 2089be8..77fd021 100644 --- a/src/main/java/com/inteligr8/maven/aps/modeling/util/Index.java +++ b/src/main/java/com/inteligr8/maven/aps/modeling/util/Index.java @@ -132,6 +132,11 @@ public class Index { * @return true if the key already existed and was overwritten; false otherwise. */ public synchronized boolean put(K key, V value) { + if (key == null) + throw new IllegalArgumentException("An index key may not be null"); + if (value == null) + throw new IllegalArgumentException("An index value may not be null"); + boolean overwrote = false; V oldValue = this.forwardMap.get(key); @@ -159,6 +164,9 @@ public class Index { * @return true if the key and its value were removed; false otherwise. */ public synchronized boolean remove(K key) { + if (key == null) + throw new IllegalArgumentException("An index key may not be null"); + V oldValue = this.forwardMap.remove(key); if (oldValue == null) return false;