Skip to content

Fix Java ISO_INSTANT timestamp validation #316

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

Merged
merged 1 commit into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/source/spec/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3082,8 +3082,8 @@ in JSON.
- number | string
- If a number is provided, it represents Unix epoch seconds with optional
millisecond precision. If a string is provided, it MUST be a valid
:rfc:`3339` string with optional millisecond precision
(e.g., ``1990-12-31T23:59:60Z``).
:rfc:`3339` string with optional millisecond precision and no
UTC offset (for example, ``1990-12-31T23:59:60Z``).
* - list
- array
- Each value in the array MUST be compatible with the referenced member.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ private List<String> validateDatetime(Shape shape, Node value) {
}

String timestamp = value.expectStringNode().getValue();
if (isValidFormat(timestamp, DATE_TIME_Z)) {
// Newer versions of Java support parsing instants that have an offset.
// See: https://bugs.openjdk.java.net/browse/JDK-8166138
// However, Smithy doesn't allow offsets for timestamp shapes.
if (timestamp.endsWith("Z") && isValidFormat(timestamp, DATE_TIME_Z)) {
return ListUtils.of();
} else {
return ListUtils.of(
Expand Down