From 5700e558f836437a2c6a6b7495a2f182399aa335 Mon Sep 17 00:00:00 2001 From: Igor Perepelitsa Date: Thu, 27 Feb 2025 17:39:07 +1000 Subject: [PATCH] Fixed NPE in ImageCommand.finished() when ImageCommand.setErrorConsumer() used --- .gitignore | 6 ++++++ .../com/github/geko444/im4java/core/ImageCommand.java | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e9b3744 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# IntelliJ project files +.idea +*.iml +out +gen +target diff --git a/src/main/java/com/github/geko444/im4java/core/ImageCommand.java b/src/main/java/com/github/geko444/im4java/core/ImageCommand.java index 2da6532..469f6a5 100644 --- a/src/main/java/com/github/geko444/im4java/core/ImageCommand.java +++ b/src/main/java/com/github/geko444/im4java/core/ImageCommand.java @@ -249,12 +249,12 @@ public ProcessTask getProcessTask(Operation pOperation, Object... images) protected void finished(int pReturnCode) throws Exception { if (pReturnCode > 0) { CommandException ce; - if (iErrorText.size() > 0) { - ce = new CommandException(iErrorText.get(0)); + if (iErrorText != null && iErrorText.size() > 0) { + ce = new CommandException("return code: " + pReturnCode + " " + iErrorText.get(0)); + ce.setErrorText(iErrorText); } else { - ce = new CommandException("return code: " + pReturnCode); + ce = new CommandException("return code: " + pReturnCode); } - ce.setErrorText(iErrorText); ce.setReturnCode(pReturnCode); throw ce; } else {