Repository navigation
[2.x] Validate RFC 3339 fractional seconds in time format - #1315
Merged
stevehu merged 1 commit intoOct 13, 2026
Merged
Conversation
Signed-off-by: dlwlrma <965810157@qq.com>
This was referenced Oct 13, 2026
stevehu
approved these changes
Oct 13, 2026
stevehu
left a comment
Contributor
There was a problem hiding this comment.
Thanks, this looks good. I reviewed #1314 and #1315 together; the changes are identical on both branches.
Verification
- #1315 on
2.x(Java 8, 11, 21) and #1314 onmaster(JDK 17, 25):TimeFormatTest(29), the JSON Schema Test Suite (7261), the extras and the format tests pass. - Revert check: with the base
TimeFormat, 7 of the new tests fail: the 4 empty-fraction cases and the 3 ten-digit cases. - 400k generated inputs compared against an RFC 3339 reference: 0 mismatches on all five JDKs. Before this change, these fraction cases were the only mismatches.
- 29 adversarial inputs aimed at the rewrite all matched the reference on Java 8 and JDK 25. They cover dots in odd places, several dots, trailing text after a long fraction, the Java 8
+HH:MM:SSoffset after a long fraction, and leap seconds with long fractions. A 1M-digit fraction takes about 1 ms.
Optional, not blocking
- Since
matches()never readsNANO_OF_SECOND, the rewrite could drop the fraction entirely (value.substring(0, decimalPoint) + value.substring(fractionEnd)) instead of keeping 9 digits. - Tests worth adding:
12:00:00.1234567890Zjunkand12:00:00.1234567890+01:00:00as invalid, and a ~100-digit fraction as valid. These are the paths whereparsedValueandvaluediffer. - The
date-timeside of #1311 (more than 9 digits rejected; empty fraction accepted by thejava.timefallback) is now tracked in #1316.
Approving. We'll merge #1314 and #1315 together once CI passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
timeformat accepts12:00:00.Zbut rejects12:00:00.1234567890Zon the 2.x branch. RFC 3339 requires at least one digit after.and permits more than nine digits.Check the fraction before parsing and shorten only the validation copy to nine digits, which is Java's parser limit. The existing offset, range, and leap-second checks remain in place. Added regression cases for empty fractions, longer fractions, and malformed trailing text.
Tested with
mvn clean verifyon JDK 8, 11, 17, and 21 (8,673 tests, 0 failures or errors, 15 skipped on each).Related to #1311.