[ https://issues.apache.org/jira/browse/AVRO-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16693050#comment-16693050 ]
ASF GitHub Bot commented on AVRO-2244: -------------------------------------- Fokko closed pull request #386: Test and fix for AVRO-2244 URL: https://github.com/apache/avro/pull/386 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java b/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java index ba8923980..02bea73bd 100644 --- a/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java +++ b/lang/java/avro/src/test/java/org/apache/avro/specific/TestSpecificLogicalTypes.java @@ -27,7 +27,6 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.ChronoField; -import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; @@ -46,6 +45,7 @@ import org.joda.time.DateTimeZone; import org.joda.time.LocalDate; import org.joda.time.LocalTime; +import org.joda.time.chrono.ISOChronology; import org.joda.time.format.ISODateTimeFormat; import org.junit.Assert; import org.junit.Rule; @@ -119,8 +119,8 @@ public void testRecordWithJsr310LogicalTypes() throws IOException { 3019.34, null, java.time.LocalDate.now(), - java.time.LocalTime.now().truncatedTo(ChronoUnit.MILLIS), - java.time.Instant.now().truncatedTo(ChronoUnit.MILLIS), + java.time.LocalTime.now(), + java.time.Instant.now(), new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN) ); @@ -133,6 +133,7 @@ public void testRecordWithJsr310LogicalTypes() throws IOException { @Test public void testAbilityToReadJsr310RecordWrittenAsJodaRecord() throws IOException { + TestRecordWithLogicalTypes withJoda = new TestRecordWithLogicalTypes( true, 34, @@ -142,7 +143,10 @@ public void testAbilityToReadJsr310RecordWrittenAsJodaRecord() throws IOExceptio null, LocalDate.now(), LocalTime.now(), - DateTime.now().withZone(DateTimeZone.UTC), + // There is no reliable way to get fixed width string from ISO_INSTANT below + // for granularity less than one second second. + new DateTime((System.currentTimeMillis() / 1000) * 1000, + ISOChronology.getInstance()).withZone(DateTimeZone.UTC), new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN) ); @@ -162,7 +166,7 @@ public void testAbilityToReadJsr310RecordWrittenAsJodaRecord() throws IOExceptio Assert.assertThat(ISO_LOCAL_DATE.format(withJsr310.getD()), is(ISODateTimeFormat.date().print(withJoda.getD()))); Assert.assertThat(ISO_LOCAL_TIME.format(withJsr310.getT()), is(ISODateTimeFormat.time().print(withJoda.getT()))); - Assert.assertThat(ISO_INSTANT.format(withJsr310.getTs()), is(ISODateTimeFormat.dateTime().print(withJoda.getTs()))); + Assert.assertThat(ISO_INSTANT.format(withJsr310.getTs()), is(ISODateTimeFormat.dateTimeNoMillis().print(withJoda.getTs()))); Assert.assertThat(withJsr310.getDec(), comparesEqualTo(withJoda.getDec())); } @@ -176,8 +180,8 @@ public void testAbilityToReadJodaRecordWrittenAsJsr310Record() throws IOExceptio 3019.34, null, java.time.LocalDate.now(), - java.time.LocalTime.now().truncatedTo(ChronoUnit.MILLIS), - java.time.Instant.now().truncatedTo(ChronoUnit.MILLIS), + java.time.LocalTime.now(), + java.time.Instant.now(), new BigDecimal(123.45f).setScale(2, BigDecimal.ROUND_HALF_DOWN) ); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Problems with > TestSpecificLogicalTypes.testAbilityToReadJsr310RecordWrittenAsJodaRecord:148 > ------------------------------------------------------------------------------------------- > > Key: AVRO-2244 > URL: https://issues.apache.org/jira/browse/AVRO-2244 > Project: Apache Avro > Issue Type: Bug > Components: logical types > Reporter: Raymie Stata > Assignee: Thiruvalluvan M. G. > Priority: Major > Fix For: 1.9.0 > > > I've seen an intermittent test failure that looks like this: > {{Failed tests:}} > {{ > TestSpecificLogicalTypes.testAbilityToReadJsr310RecordWrittenAsJodaRecord:148}} > {{Expected: is "20:35:18.720"}} > {{ but: was "20:35:18.72"}} > When I see this failure, it's always the case that the trailing digit is > zero. I suspect that it's a bug where the trailing zero is not printed. > Since the test cases use the current time, then most of the time the trailing > digit isn't zero and the bug isn't tickled. But once-in-a-while the current > time has a trailing zero, which tickles the bug. > If this diagnosis is correct, then in addition to fixing the bug, it might be > a good idea to add tests with hard-wired, static times that cover corner > cases like this one. -- This message was sent by Atlassian JIRA (v7.6.3#76005)