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

Quarkus REST: various issues with lastModified dates #41110

Closed
FroMage opened this issue Jun 11, 2024 · 2 comments · Fixed by #41123
Closed

Quarkus REST: various issues with lastModified dates #41110

FroMage opened this issue Jun 11, 2024 · 2 comments · Fixed by #41123
Assignees
Labels
area/rest kind/bug Something isn't working
Milestone

Comments

@FroMage
Copy link
Member

FroMage commented Jun 11, 2024

Describe the bug

  • ResponseBuilder.lastModified will use whatever user-configured ParamConverter for Date, which is wrong, because HTTP date headers must be formatted in a special way, otherwise we will fail parsing them
  • Calling Request.evaluatePreconditions(Date) is very likely to never work, because Date is millisecond-precision, whereas HTTP headers are second-precision, so there's 999/1000 chances that the date we're passed will be later than the (truncated) header, unless the user applies this truncation beforehand (and knows about it). We should truncate it ourselves, because we only operate on second-precision due to HTTP limitations.

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@FroMage FroMage added the kind/bug Something isn't working label Jun 11, 2024
Copy link

quarkus-bot bot commented Jun 11, 2024

/cc @stuartwdouglas (resteasy-reactive)

@FroMage
Copy link
Member Author

FroMage commented Jun 11, 2024

Apparently, the problem is not ParamConverter<Date> because those are not used for headers, contrary to intuition, these are under the responsability of RuntimeDelegate.HeaderDelegate<Date>, and the problem is due to Hibernate generating Date values which are of a subclass of java.util.Date, and createHeaderDelegate(Class) is an exact match, so Object.toString() is used, which is invalid:

        } else if (type.equals(Date.class)) {
            return (HeaderDelegate<T>) DateDelegate.INSTANCE;
...
        } else {
            return (HeaderDelegate<T>) ObjectToStringDelegate.INSTANCE;
        }

FroMage added a commit to FroMage/quarkus that referenced this issue Jun 11, 2024
- Round Dates to second precision when comparing them
- Lookup header delegate for Date and subtypes

Fixes quarkusio#41110
@quarkus-bot quarkus-bot bot added this to the 3.13 - main milestone Jun 12, 2024
@gsmet gsmet modified the milestones: 3.13 - main, 3.12.0 Jun 14, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jun 14, 2024
- Round Dates to second precision when comparing them
- Lookup header delegate for Date and subtypes

Fixes quarkusio#41110

(cherry picked from commit 07b3f94)
@gsmet gsmet modified the milestones: 3.12.0, 3.11.3 Jun 18, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jun 18, 2024
- Round Dates to second precision when comparing them
- Lookup header delegate for Date and subtypes

Fixes quarkusio#41110

(cherry picked from commit 07b3f94)
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Jul 31, 2024
- Round Dates to second precision when comparing them
- Lookup header delegate for Date and subtypes

Fixes quarkusio#41110
@gsmet gsmet modified the milestones: 3.11.3, 3.8.6 Aug 14, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Aug 14, 2024
- Round Dates to second precision when comparing them
- Lookup header delegate for Date and subtypes

Fixes quarkusio#41110

(cherry picked from commit 07b3f94)
danielsoro pushed a commit to danielsoro/quarkus that referenced this issue Sep 20, 2024
- Round Dates to second precision when comparing them
- Lookup header delegate for Date and subtypes

Fixes quarkusio#41110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants