From e2b9351662d2e3df418dc59481fd44e87d31301e Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 6 Mar 2018 13:12:02 +1100 Subject: [PATCH] Avoid NPE in exception for bad version #2284 Signed-off-by: Greg Wilkins --- .../src/main/java/org/eclipse/jetty/start/StartArgs.java | 4 +++- .../main/java/org/eclipse/jetty/start/UsageException.java | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java index 5e853120acd..ed06cfc48a7 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java @@ -1275,7 +1275,9 @@ public class StartArgs } catch (Throwable x) { - throw new UsageException(UsageException.ERR_BAD_ARG, x.getMessage()); + UsageException ue = new UsageException(UsageException.ERR_BAD_ARG, x.getMessage()==null?x.toString():x.getMessage()); + ue.initCause(x); + throw ue; } } } diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/UsageException.java b/jetty-start/src/main/java/org/eclipse/jetty/start/UsageException.java index ace7feb6fb5..c123b089686 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/UsageException.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/UsageException.java @@ -33,6 +33,12 @@ public class UsageException extends RuntimeException public static final int ERR_UNKNOWN = -9; private int exitCode; + public UsageException(int exitCode, String message) + { + super(message); + this.exitCode = exitCode; + } + public UsageException(int exitCode, String format, Object... objs) { super(String.format(format,objs));