Skip to content

Commit 4ceb1b9

Browse files
vladakahornace
authored andcommitted
handle null parameters more gracefully
1 parent 2ce4a75 commit 4ceb1b9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

plugins/src/main/java/opengrok/auth/plugin/UserWhiteListPlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public class UserWhiteListPlugin implements IAuthorizationPlugin {
5757

5858
@Override
5959
public void load(Map<String, Object> parameters) {
60+
if (parameters == null) {
61+
throw new IllegalArgumentException("Null parameter");
62+
}
63+
6064
String filePath;
6165
if ((filePath = (String) parameters.get(FILE_PARAM)) == null) {
6266
throw new IllegalArgumentException("Missing parameter [" + FILE_PARAM + "] in the configuration");

plugins/src/test/java/opengrok/auth/plugin/UserWhiteListPluginTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void init(String param) {
117117
@MethodSource("parameters")
118118
public void shouldThrowOnLoadIfNullArgument(String param) {
119119
init(param);
120-
assertThrows(NullPointerException.class, () -> {
120+
assertThrows(IllegalArgumentException.class, () -> {
121121
//noinspection ConstantConditions
122122
plugin.load(null);
123123
}, "plugin.load(null)");

0 commit comments

Comments
 (0)