SAP / sap-commerce-db-sync

SAP Commerce extensions to perform table-to-table replication in single-directionally manner between two SAP Commerce instances or between SAP Commerce and an external database.
Apache License 2.0
28 stars 12 forks source link

NPE When status is "stalled" #28

Closed hadasdavid closed 2 months ago

hadasdavid commented 4 months ago

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) ~[?:?]
hadasdavid commented 3 months ago

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"))