Yes we can use the truncate approach as implementation for
Instant.nowInMillis. Just that this change is needed in quite a few
places. So looking for least intrusive approach

Chetan Mehrotra

On Wed, May 29, 2019 at 4:05 AM Matt Sicker <boa...@gmail.com> wrote:
>
> Isn’t there a truncate method on most of the temporal classes? You can
> truncate to milliseconds.
>
> On Tue, May 28, 2019 at 10:02, Chetan Mehrotra <chetan.mehro...@gmail.com>
> wrote:
>
> > Hi Team,
> >
> > As part of supporting JDK 11 I am seeing some test failure due to
> > change in behavior of way java.time.Instant now works. As noted in [1]
> > [2] with JDK 11 Instant.now is constructed with microsecond precision
> > [3] compared to millisecond in JDK 8 [4].
> >
> > This causes issue when entities in test are compared after and before
> > persisting in DB. When we store the entity in DB then its stored with
> > millisecond precision while the in memory entity refers to Instant
> > value with microsecond precision which leads to test failures [5] when
> > such entity instances are checked for equality.
> >
> > So far my understanding is that this change in behaviour impacts on
> > test code and most likely it should not impact production code.
> >
> > So need to find a way to retain old behaviour for Instant. Possible options
> >
> > 1. Create an extension method for Instant like `Instant.nowInMillis`
> > and use that in Test case
> > 2. Use a custom `WhiskInstant` in our entity classes to have full
> > control on precision
> >
> > Any other which team may suggest
> >
> > Thoughts?
> >
> > Chetan Mehrotra
> > [1]
> > https://github.com/apache/incubator-openwhisk/issues/4217#issuecomment-496469481
> > [2] https://github.com/h2database/h2database/issues/1178
> > [3]
> > https://github.com/openjdk/jdk/blob/jdk-11%2B28/src/java.base/share/classes/java/time/Clock.java#L524
> > [4]
> > https://github.com/openjdk/jdk/blob/jdk8-b120/jdk/src/share/classes/java/time/Clock.java#L470
> > [5] https://scans.gradle.com/s/sf7udehikj6g2/tests/failed
> >
> --
> Matt Sicker <boa...@gmail.com>

Reply via email to