Added check for null values in collection passed to CompilerConfiguration.
This commit is contained in:
@@ -70,6 +70,7 @@ public class CompilerConfiguration {
|
|||||||
|
|
||||||
public <T> void addAll(@NotNull CompilerConfigurationKey<List<T>> key, @NotNull Collection<T> values) {
|
public <T> void addAll(@NotNull CompilerConfigurationKey<List<T>> key, @NotNull Collection<T> values) {
|
||||||
checkReadOnly();
|
checkReadOnly();
|
||||||
|
checkForNullElements(values);
|
||||||
Key<List<T>> ideaKey = key.ideaKey;
|
Key<List<T>> ideaKey = key.ideaKey;
|
||||||
if (map.get(ideaKey) == null) {
|
if (map.get(ideaKey) == null) {
|
||||||
map.put(ideaKey, new ArrayList<T>());
|
map.put(ideaKey, new ArrayList<T>());
|
||||||
@@ -112,4 +113,15 @@ public class CompilerConfiguration {
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <T> void checkForNullElements(Collection<T> values) {
|
||||||
|
int index = 0;
|
||||||
|
for (T value : values) {
|
||||||
|
if (value == null) {
|
||||||
|
throw new IllegalArgumentException("Element " + index
|
||||||
|
+ " is null, while null values in compiler configuration are not allowed");
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user