From: Niels Erik G. Nielsen Date: Tue, 1 Oct 2013 00:30:16 +0000 (-0400) Subject: Avoid npe on attempt to remove non-existing parameter X-Git-Tag: v0.0.7~16 X-Git-Url: http://jsfdemo.indexdata.com/?a=commitdiff_plain;h=74ea81b22375676bf687d614161c19f268289e39;p=mkjsf-moved-to-github.git Avoid npe on attempt to remove non-existing parameter --- diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java index 82ac066..f61642c 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java @@ -267,12 +267,14 @@ public abstract class Pazpar2Command implements Serializable { } public void removeExpressions(String parameterName, String... expressionFields) { - Pazpar2Command copy = this.copy(); - copy.getParameter(parameterName).removeExpressions(expressionFields); - if (!getParameter(parameterName).hasValue() && !getParameter(parameterName).hasExpressions()) { - copy.parameters.remove(parameterName); + if (this.getParameter(parameterName) != null) { + Pazpar2Command copy = this.copy(); + copy.getParameter(parameterName).removeExpressions(expressionFields); + if (!getParameter(parameterName).hasValue() && !getParameter(parameterName).hasExpressions()) { + copy.parameters.remove(parameterName); + } + checkInState(copy); } - checkInState(copy); } public boolean hasParameters () {