Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration test fails on JDK > 8 because of Instant resolution change #571

Closed
fkomauli opened this issue Dec 1, 2022 · 0 comments · Fixed by #572
Closed

Integration test fails on JDK > 8 because of Instant resolution change #571

fkomauli opened this issue Dec 1, 2022 · 0 comments · Fixed by #572
Labels
type: bug A general bug
Milestone

Comments

@fkomauli
Copy link
Contributor

fkomauli commented Dec 1, 2022

Integration tests failure

Test AbstractCodecIntegrationTests::localDateTime fails because it serializes an Instant.now() value and compares it with the deserialized one without truncating it to microseconds.

The test completes successfully on JDK 8 as the Instant resolution is in milliseconds, but fails on JDK 17.

Truncation to microseconds was already used in the same test for LocalDateTimes, and was forgotten out for the Instant case.

Fix

diff --git a/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java b/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java
index 1cd585a..daf3d64 100644
--- a/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java
+++ b/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java
@@ -435,7 +435,7 @@ abstract class AbstractCodecIntegrationTests extends AbstractIntegrationTests {
         testCodec(LocalDateTime.class, LocalDateTime.now().truncatedTo(ChronoUnit.MICROS), "TIMESTAMP");
         testCodec(LocalDateTime.class, LocalDateTime.now().truncatedTo(ChronoUnit.MICROS), "TIMESTAMPTZ");
 
-        Instant now = Instant.now();
+        Instant now = Instant.now().truncatedTo(ChronoUnit.MICROS);
         LocalDateTime ldt = now.atZone(ZoneId.systemDefault()).toLocalDateTime();
         testCodec(LocalDateTime.class, ldt, Instant.class, (actual, expected) -> {
@fkomauli fkomauli added the status: waiting-for-triage An issue we've not yet triaged label Dec 1, 2022
fkomauli pushed a commit to optionfactory/r2dbc-postgresql that referenced this issue Dec 1, 2022
mp911de pushed a commit that referenced this issue Dec 7, 2022
mp911de pushed a commit that referenced this issue Dec 7, 2022
@mp911de mp911de added this to the 1.0.1.RELEASE milestone Dec 7, 2022
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
2 participants