@PastOrPresent-Validation possibly bugged (comparison stuck to application startup time)

Jmix Version: 2.2.1.1
Plugin Version: 2.2.1-233

Observed behavior:
When annotating either a LocalDate or a LocalDateTime with @PastOrPresent, the validation seems to check against the startup time of the application, not against the current time as expected.

Steps to reproduce:

  1. Create a new Jmix project
  2. Add one Entity with a LocalDateTime field
  3. Add a @PastOrPresent validator to this field
  4. Add a view for the entity which allows creation of a new instance
  5. Start the application
  6. Try to create a new entity with current local date time as observed from the local system clock
  7. Wait 2 Minutes
  8. Try to create a new entity with current local date time as observed from the local system clock minus one minute
  9. Observe that the validation fails

Notes:

  • Unfortunately I could not load up a zip archive of a minimal example (as described above) as it exceeded the max size of 4MB slightly. Please consider raising the upload limit.
  • I also made a small video demonstrating the effect, but could not upload it as a/ .mp4 files are not accepted and b/ .mov files are bigger than 4MB. Please consider accepting mp4 files. I have now uploaded the video to the public internet.
  • I have successfully reproduced this both for LocalDate and LocalDateTime fields. I also suspect that this behavior might be present for other temporals.
  • The behavior appears to be platform idenpendent as I could both verify it under MacOS as well as in a docker container running inside Ubuntu.
  • Superficial investigation suggests that maybe the root cause can be found in ValidationClockProvider (package io.jmix.core.impl.validation) line 37: return Clock.fixed(now.toInstant(), now.getZone()); - maybe the Clock.fixed might be the issue.
  • If this is indeed the case, I would suspect that the behavior is not limited to this validator alone.

Thank you for investigating and best regards,

Dominik

Hi Dominik,

Thank you very much for the excellent explanation and the analysis. I’ve created and issue for the problem.