From 74ea81b22375676bf687d614161c19f268289e39 Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Mon, 30 Sep 2013 20:30:16 -0400 Subject: [PATCH] Avoid npe on attempt to remove non-existing parameter --- .../indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 () { -- 1.7.10.4