Skip to content

8380549: HttpCookie.expiryDate2DeltaSeconds returns 0 on parse failure, causing immediate cookie expiration#30341

Open
ehs208 wants to merge 1 commit intoopenjdk:masterfrom
ehs208:JDK-HttpCookie-expiryDate-parse-failure
Open

8380549: HttpCookie.expiryDate2DeltaSeconds returns 0 on parse failure, causing immediate cookie expiration#30341
ehs208 wants to merge 1 commit intoopenjdk:masterfrom
ehs208:JDK-HttpCookie-expiryDate-parse-failure

Conversation

@ehs208
Copy link
Contributor

@ehs208 ehs208 commented Mar 20, 2026

When expiryDate2DeltaSeconds() fails to parse the Expires attribute against all date formats, it returns 0. The caller in assignMaxAgeAttribute() then sets maxAge=0, which causes hasExpired() to return true. Per RFC 6265 section 5.2.1, an unparseable Expires value should be ignored, leaving maxAge=-1 (session cookie).

This fix introduces a sentinel constant (Long.MIN_VALUE) as the return value for parse failure, since 0 is a valid delta for dates that match the creation time. The caller checks for this sentinel and skips the maxAge assignment when parsing fails.

A new test in MaxAgeExpires verifies that unparseable Expires values are correctly ignored.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8380549: HttpCookie.expiryDate2DeltaSeconds returns 0 on parse failure, causing immediate cookie expiration (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30341/head:pull/30341
$ git checkout pull/30341

Update a local copy of the PR:
$ git checkout pull/30341
$ git pull https://git.openjdk.org/jdk.git pull/30341/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30341

View PR using the GUI difftool:
$ git pr show -t 30341

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30341.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 20, 2026

👋 Welcome back ehs208! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Mar 20, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the net net-dev@openjdk.org label Mar 20, 2026
@openjdk
Copy link

openjdk bot commented Mar 20, 2026

@ehs208 The following label will be automatically applied to this pull request:

  • net

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 20, 2026
@mlbridge
Copy link

mlbridge bot commented Mar 20, 2026

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

net net-dev@openjdk.org rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

1 participant