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

Timestamp validation is technically wrong (Java 12 test failures) #155

Closed
webern opened this issue Sep 6, 2019 · 2 comments
Closed

Timestamp validation is technically wrong (Java 12 test failures) #155

webern opened this issue Sep 6, 2019 · 2 comments
Labels
bug This issue is a bug. GA

Comments

@webern
Copy link

webern commented Sep 6, 2019

There was a bug in DateTimeFormatter.ISO_INSTANT that was fixed in Java 12. Here is the link to that bug:
https://bugs.openjdk.java.net/browse/JDK-8166138

This change exposes certain tests in

smithy-model/src/test/java/software/amazon/smithy/model/validation/NodeValidationVisitorTest.java

which rely on the incorrect, pre Java 12 behavior of DateTimeFormatter.ISO_INSTANT
For example, it is asserted that the following string should fail timestamp validation:

2000-01-12T22:11:12+01:02

In fact, this is a valid RFC 3389 time representation.
In Java versions prior to 12, DateTimeFormatter.ISO_INSTANT incorrectly throws for this parse, and the test which relies on this incorrect behavior passes.
In Java version 12, the Java SDK bug was fixed and the test fails because the string is a valid timestamp and Java no longer throws on the parse.

Bottom line: there are some tests that fail in Java 12.

@mtdowling
Copy link
Member

Good find! We might have to just switch to a regex based validator. RFC 3339 isn't that complex based on the ABNF (we only support date-time):

date-fullyear   = 4DIGIT
date-month      = 2DIGIT  ; 01-12
date-mday       = 2DIGIT  ; 01-28, 01-29, 01-30, 01-31 based on
                            ; month/year
time-hour       = 2DIGIT  ; 00-23
time-minute     = 2DIGIT  ; 00-59
time-second     = 2DIGIT  ; 00-58, 00-59, 00-60 based on leap second
                            ; rules
time-secfrac    = "." 1*DIGIT
time-numoffset  = ("+" / "-") time-hour ":" time-minute
time-offset     = "Z" / time-numoffset

partial-time    = time-hour ":" time-minute ":" time-second
                    [time-secfrac]
full-date       = date-fullyear "-" date-month "-" date-mday
full-time       = partial-time time-offset

date-time       = full-date "T" full-time

@mtdowling mtdowling added the bug This issue is a bug. label Sep 19, 2019
@mtdowling mtdowling added the GA label Feb 26, 2020
mtdowling added a commit that referenced this issue Mar 15, 2020
mtdowling added a commit that referenced this issue Mar 16, 2020
@mtdowling
Copy link
Member

Looking at this again, Smithy doesn't actually timestamp offsets, all we need to do is validate that timestamp strings end with "Z". c5aa1d7

mtdowling added a commit that referenced this issue Mar 16, 2020
JordonPhillips pushed a commit to JordonPhillips/smithy that referenced this issue Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. GA
Projects
None yet
Development

No branches or pull requests

2 participants