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

8291637: HttpClient default keep alive timeout not followed if server sends invalid value #9755

Closed

Conversation

Michael-Mc-Mahon
Copy link
Member

@Michael-Mc-Mahon Michael-Mc-Mahon commented Aug 4, 2022

Hi,

Some new keep alive tests are exposing some old bugs. In this case if the server sends an invalid timeout (say -20 seconds) we accept it creating a timeout in the past. So, the first time the keep alive thread wakes up it will close the connection.
The correct behavior is to ignore the invalid parameter and fallback to the default timeout or the timeout set by the relevant system property.

Thanks,
Michael


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-8291637: HttpClient default keep alive timeout not followed if server sends invalid value

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9755

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 4, 2022

👋 Welcome back michaelm! 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 openjdk bot added the rfr Pull request is ready for review label Aug 4, 2022
@openjdk
Copy link

openjdk bot commented Aug 4, 2022

@Michael-Mc-Mahon 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 net net-dev@openjdk.org label Aug 4, 2022
@mlbridge
Copy link

mlbridge bot commented Aug 4, 2022

Webrevs

@@ -901,6 +901,11 @@ private boolean parseHTTPHeader(MessageHeader responses, ProgressSource pi, Http
/* default should be larger in case of proxy */
keepAliveConnections = p.findInt("max", usingProxy?50:5);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Michael, should we do something similar for this max parameter value too and (re)set the keepAliveConnections to the defaults, if the server sends a negative value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a good suggestion. Will do.

/*
* @test
* @bug 8291637
* @run main/othervm -Dhttp.keepAlive.time.server=20 -esa -ea B8291637
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional that we are setting the -esa and -ea options here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we enable assertions without the bug fix, then an assertion is triggered in KeepAliveCache, which is useful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests are usually run with -esa -ea in our test systems, but individual developers could "forget" to specify those options. So in the case where it's the only thing that would make the test fail without the fix (or in the case where it would provide additional diagnostic for the particular bug fix) it can make sense to add them in the @run too...

System.out.println("Time diff = " + diff);
}
} catch (IOException e) {
System.err.println("Server exception terminating");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me that if an exception occurs (not just IOException) then this test might hang (and timeout with the jtreg timeout) at the passed.get() call in the main() method. Should we perhaps catch Throwable here and do passed.completeExceptionally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable.

Copy link
Member

@jaikiran jaikiran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes, Michael. The updated version looks fine to me.

@openjdk
Copy link

openjdk bot commented Aug 5, 2022

@Michael-Mc-Mahon This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8291637: HttpClient default keep alive timeout not followed if server sends invalid value

Reviewed-by: jpai, dfuchs

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 16 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 5, 2022
public void close() {
try {
serverSocket.close();
s.close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could that trigger a NPE if s is null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could happen only if ServerSocket.accept throws an exception, which I guess is possible. But, the client side would not get to call Server.close then. I'll add a check anyway.

Copy link
Member

@dfuch dfuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM too

@Michael-Mc-Mahon
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Aug 5, 2022

Going to push as commit b17a745.
Since your change was applied there have been 16 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 5, 2022
@openjdk openjdk bot closed this Aug 5, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 5, 2022
@openjdk
Copy link

openjdk bot commented Aug 5, 2022

@Michael-Mc-Mahon Pushed as commit b17a745.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@Michael-Mc-Mahon
Copy link
Member Author

/help

@Michael-Mc-Mahon Michael-Mc-Mahon deleted the negKeepAlive branch August 5, 2022 15:02
@openjdk
Copy link

openjdk bot commented Aug 5, 2022

@Michael-Mc-Mahon Available commands:

  • backport - create a backport
  • help - shows this text
  • tag - create a tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated net net-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants