sap-commerce-db-sync
sap-commerce-db-sync copied to clipboard
NPE When status is "stalled"
When the Migration Status is set to SLATTED, the following logging in CustomClusterDatabaseCopyScheduler.java fails due to NullPointerException as the Start Date or endDate are null:
LOG.info("Migration {} ({}) in {}", endState, status.getStatus(), DurationFormatUtils .formatDurationHMS(Duration.between(status.getStart(), status.getEnd()).toMillis()));
java.lang.NullPointerException: temporal
at java.util.Objects.requireNonNull(Objects.java:235) ~[?:?]
at java.time.LocalDate.from(LocalDate.java:394) ~[?:?]
at java.time.LocalDateTime.from(LocalDateTime.java:458) ~[?:?]
at java.time.LocalDateTime.until(LocalDateTime.java:1677) ~[?:?]
at java.time.Duration.between(Duration.java:490) ~[?:?]
at com.sap.cx.boosters.commercedbsync.scheduler.impl.CustomClusterDatabaseCopyScheduler$MigrationMonitor.logState(CustomClusterDatabaseCopyScheduler.java:347) ~[commercedbsyncserver.jar:?]
at com.sap.cx.boosters.commercedbsync.scheduler.impl.CustomClusterDatabaseCopyScheduler$MigrationMonitor.pollState(CustomClusterDatabaseCopyScheduler.java:294) ~[commercedbsyncserver.jar:?]
at com.sap.cx.boosters.commercedbsync.scheduler.impl.CustomClusterDatabaseCopyScheduler$MigrationMonitor.run(CustomClusterDatabaseCopyScheduler.java:269) ~[commercedbsyncserver.jar:?]
at java.lang.Thread.run(Thread.java:840) ~[?:?]
Maybe the fix should be in DefaultDatabaseCopyTaskRepository.convertToStatus()
Something like adding a condition to status.setEnd()
status.setEnd(MigrationProgress.STALLED == status.getStatus() ? now() : getDateTime(rs, "endAt"))