From ec42a6e75ad85cca2cc24a1c7cd402fd154f3f3d Mon Sep 17 00:00:00 2001 From: giavaphi Date: Mon, 28 Nov 2022 12:38:29 +0100 Subject: [PATCH] fix nullpointer exception check date garden schedule --- .../gartenverwaltung/models/GardenSchedule.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java b/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java index a3eccfa..6f63f11 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java @@ -147,12 +147,14 @@ public class GardenSchedule { final int finalI = i; weekTasks.forEach(task -> { LocalDate checkDate = task.getNextExecution(); - do { - if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) { - dayTaskList.get(finalI).add(task); - } - checkDate = checkDate.plusDays(task.getInterval().orElse(0)); - } while (!(task.getInterval().orElse(0) == 0) && checkDate.isBefore(LocalDate.now().plusDays(listLength))); + if (checkDate != null) { + do { + if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) { + dayTaskList.get(finalI).add(task); + } + checkDate = checkDate.plusDays(task.getInterval().orElse(0)); + } while (!(task.getInterval().orElse(0) == 0) && checkDate.isBefore(LocalDate.now().plusDays(listLength))); + } }); } return dayTaskList;