-
Notifications
You must be signed in to change notification settings - Fork 914
Add more tests to verify connection closure and small code clean up #1034
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1034 +/- ##
============================================
+ Coverage 55.57% 55.65% +0.07%
- Complexity 4590 4598 +8
============================================
Files 815 815
Lines 27906 27918 +12
Branches 2246 2246
============================================
+ Hits 15509 15538 +29
+ Misses 11676 11658 -18
- Partials 721 722 +1
Continue to review full report at Codecov.
|
|
||
@Override | ||
public void close() { | ||
isClosed = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: any reason not to call super.close()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per javadoc, ByteArrayInputStream#close
has no effect.
Closing a {@code ByteArrayInputStream} has no effect.
client.streamingOutputOperation(b -> b.build(), new ResponseTransformer<StreamingOutputOperationResponse, Object>() { | ||
|
||
@Override | ||
public Object transform(StreamingOutputOperationResponse response, AbortableInputStream inputStream) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding a similar test where we return the inputStream
, and then call close()
and then check to see that the wrapped InputStream
is closed?
We could look into a similar test for async
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, will add that test.
I thought about adding a similar test for async but unlike sync where connections are being closed by closing the inputStream, channels are being released in the netty module so there's no easy way to verify that here.
7e1ca53
to
980b09d
Compare
…69f3a15f9 Pull request: release <- staging/750488da-2bcf-4605-aef6-f0669f3a15f9
Description
Reviewed all use of connection closure and verified the resources are being properly released/closed/shutdown after each request as well as after invoke
client#close
.This PR added more tests to verify the correctness and did some small code cleanup.
Summary of Connection Closure
Per Request
Sockets are being closed by closing the underlying
InputStream
via HandleResponseStage#closeInputStreamIfNeeded unlessneedsConnectionLeftOpen
is true (default to false).For streaming requests, if a customized
ResponseHandler
is provided withneedsConnectionLeftOpen
overriden to true, the underlying connection will not be closed.Channels are being released after each request in netty module unless
keep alive
is true via ResponseHandler#finalizeRequest (I renamed it tofinalizeResponse
in this PR)Per Client After invoking
Client#close
SDK
Closable
will be closed viaAmazonSyncHttpClient#close
andAmazonAsyncHttpClient#close
ApacheHttpClient:
HttpClientConnectionManager
will be shutdown andIdleConnectionReaper
will be cleaned up.NettyNioAyncHttpClient
EventLoopGroup
will be shutdown and channel pools will be closedUrlConnectionHttpClient
No op. Nothing to close
Let me know if I missed anything.
License