Fix http response input stream resource leak#633
Fix http response input stream resource leak#633marcuslinke merged 7 commits intodocker-java:masterfrom
Conversation
|
@marcuslinke @KostyaSha could you please check the changes? Please also note the question in the comment above. |
|
Sorry, lost comment. Could you check coverity results for master branch? Does it has complains about this resource leak? https://scan.coverity.com/projects/docker-java-docker-java?tab=overview |
|
@KostyaSha sure! I've requested the access to coverty. |
|
Hm.. you should be able to see any defects without contributor... Press "view defects" |
|
@KostyaSha when I sign in as GitHub user Coverity shows a message Want to view defects or help fix defects? with a button below Add me to project. |
|
Added as defect viewer, if you will need "triage?" please ping me. |
|
@marcuslinke for review |
|
@KostyaSha thank you! |
|
As i understand it analyses only our code and nobody knows what checks it has because it proprietary solution. |
|
Ok.. I'll try to find a solution to check generated logs for messages about |
4a85e72 to
b76acde
Compare
|
@KostyaSha @marcuslinke could you please check? Travis errors don't seem to be related with PR changes. |
| public void onError(Throwable throwable) { | ||
| if (closed) return; | ||
|
|
||
| if (this.firstError == null) { |
There was a problem hiding this comment.
please don't use this where it not required.
27bffd6 to
0cb0b08
Compare
Current coverage is 71.02% (diff: 78.94%)@@ master #633 diff @@
==========================================
Files 300 301 +1
Lines 6131 6225 +94
Methods 0 0
Messages 0 0
Branches 518 532 +14
==========================================
+ Hits 4355 4421 +66
- Misses 1526 1550 +24
- Partials 250 254 +4
|
0cb0b08 to
1871e6d
Compare
|
@KostyaSha pls review! |
|
@tejksat https://github.com/codecov/browser-extension if you would like to cover all your logic :) |
|
@tejksat i don't understand this routines, would wait bit for @marcuslinke or merge as it passes tests. |
|
@KostyaSha codecov Chrome extension is the best! Thank you! |
|
@marcuslinke there are several problems in the original code:
|
| /** | ||
| * Implementation of {@link ResultCallback} with the single result event expected. | ||
| */ | ||
| public class AsyncResultCallback<A_RES_T> implements ResultCallback<A_RES_T> { |
There was a problem hiding this comment.
This special callback class should inherit ResultCallbackTemplate ideally and should be moved into InvocationBuilder internally.
…tream.close() but rather a separate method
HttpResponseInputStream reworked not to queue incoming byte buffers. This queuing leads to the OutOfDirectMemoryError for sure when buffer elements are not processed quite fast.
bbda847 to
aac58a7
Compare
|
LGTM. Thanks @tejksat for fixing all these issues! |
|
@marcuslinke I'm glad to do that! |
there are several problems in the original code: - not releasing `ByteBuf` queued; - queuing `ByteBuf` until all data is read what effectively leads to `OutOfDirectMemoryError` if the data read is too big. This happens if you try to copy too big file or folder from a container. To fix this `ResponseCallback` (which in `awaitResult()` waits in fact for `readComplete()` channel method invocation) replaced with `AsyncResultCallback`; - actually queuing `ByteBuf` anyway leads to `OutOfDirectMemoryError` if data consumption is slower (the next point) than obtaining it; - poor performance because of the byte-by-byte reads.
there are several problems in the original code: - not releasing `ByteBuf` queued; - queuing `ByteBuf` until all data is read what effectively leads to `OutOfDirectMemoryError` if the data read is too big. This happens if you try to copy too big file or folder from a container. To fix this `ResponseCallback` (which in `awaitResult()` waits in fact for `readComplete()` channel method invocation) replaced with `AsyncResultCallback`; - actually queuing `ByteBuf` anyway leads to `OutOfDirectMemoryError` if data consumption is slower (the next point) than obtaining it; - poor performance because of the byte-by-byte reads.

According to https://github.com/netty/netty/wiki/Reference-counted-objects tests logs should be checked for an error message about a memory leak:
I don't know how to implement it in a good way. Could you please suggest?
Fixes #624
This change is