From daaf3cd65b08744d7c5f7a6115efbebdcbfb1730 Mon Sep 17 00:00:00 2001 From: Urs Joss Date: Fri, 15 Nov 2024 07:55:48 +0100 Subject: [PATCH] fix: avoid NPE found in the logs --- .../core/web/paper/entry/EditablePaperPanel.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/core-web/src/main/java/ch/difty/scipamato/core/web/paper/entry/EditablePaperPanel.java b/core/core-web/src/main/java/ch/difty/scipamato/core/web/paper/entry/EditablePaperPanel.java index d5431025d..bd3e8ba25 100644 --- a/core/core-web/src/main/java/ch/difty/scipamato/core/web/paper/entry/EditablePaperPanel.java +++ b/core/core-web/src/main/java/ch/difty/scipamato/core/web/paper/entry/EditablePaperPanel.java @@ -644,12 +644,14 @@ protected void onSubmit(@NotNull final AjaxRequestTarget target) { super.onSubmit(target); Paper p = null; final List fileUploads = model.getObject(); - for (final FileUpload upload : fileUploads) { - try { - p = paperService.saveAttachment(convertToPaperAttachment(upload)); - } catch (final Exception ex) { - log.error("Unexpected error when uploading file {}: {}", upload.getClientFileName(), ex.getMessage()); - error("Unexpected error saving file " + upload.getClientFileName() + ": " + ex.getMessage()); + if (fileUploads != null) { + for (final FileUpload upload : fileUploads) { + try { + p = paperService.saveAttachment(convertToPaperAttachment(upload)); + } catch (final Exception ex) { + log.error("Unexpected error when uploading file {}: {}", upload.getClientFileName(), ex.getMessage()); + error("Unexpected error saving file " + upload.getClientFileName() + ": " + ex.getMessage()); + } } } if (p != null) {