Skip to content

Improve connection reuse#971

Merged
ob-stripe merged 1 commit intomasterfrom
ob-fix-connection-reuse
Apr 6, 2020
Merged

Improve connection reuse#971
ob-stripe merged 1 commit intomasterfrom
ob-fix-connection-reuse

Conversation

@ob-stripe
Copy link
Contributor

@ob-stripe ob-stripe commented Feb 21, 2020

r? @brandur-stripe @richardm-stripe
cc @stripe/api-libraries

This PR should improve connection reuse in stripe-java. It does two things:

  1. the response stream is now closed after we're done reading from it. This is one the recommendations laid out in https://docs.oracle.com/javase/8/docs/technotes/guides/net/http-keepalive.html.

  2. conn.disconnect() is no longer called. The documentation for HttpURLConnection.disconnect() is as unclear as can be, but after reading multiple SO questions and blog posts, my understanding is that calling disconnect() "hints" that the underlying socket can be closed. For our case I think is unnecessary, we can leave the socket open and the JVM will close it if idles for a long time.

@ob-stripe ob-stripe force-pushed the ob-fix-connection-reuse branch from 3108606 to 14b44d6 Compare February 21, 2020 22:24
@ob-stripe ob-stripe changed the title [wip] Fix connection reuse Improve connection reuse Apr 4, 2020
Copy link
Contributor

@brandur-stripe brandur-stripe left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me! Thanks for the code simplification too. Nice.

@ob-stripe ob-stripe merged commit ec964f8 into master Apr 6, 2020
@ob-stripe ob-stripe deleted the ob-fix-connection-reuse branch April 6, 2020 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants