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

Release empty CompositeBuffers #238

Closed
wants to merge 1 commit into from

Conversation

alexwen
Copy link

@alexwen alexwen commented Sep 29, 2014

Fix for #237

Release content if not readable.

@NiteshKant
Copy link
Member

Thanks @alexwen for digging into this leak, I myself was behind this for a while but not able to point to the cause.

Looking at the code, it appears to me that the check if (content.isReadable()) is unnecessary and we should call invokeContentOnNext() unconditionally. What do you think?

PS: Apologies for the delay in response, I was out on a vacation.

@alexwen
Copy link
Author

alexwen commented Oct 6, 2014

It would be my preference as well to invokeContentOnNext unconditionally. It may break backwards compatibility in cases where folks might always be expecting the content to be readable, but it is a better behavcior, imo, to have it always emit one ByteBuf.

The current behavior has forced me to put...

response.getContent()
                    .firstOrDefault(UnpooledByteBufAllocator.DEFAULT.buffer(0, 0))

... throughout my code so I can do error handling irrespective of whether or not the server has returned a message.

@NiteshKant
Copy link
Member

It may break backwards compatibility in cases where folks might always be expecting the content to be readable, but it is a better behavcior, imo, to have it always emit one ByteBuf.

I agree, this is a better behavior. Do you want to update this PR with this change?

@alexwen
Copy link
Author

alexwen commented Oct 6, 2014

Attempting this change leads to other issues downstream, it looks like they are originating from ServerSentEvents (as the observable now receives the empty byte buffer before the closing of the stream). I don't have time to look at this too deeply at the moment, but will update the issue if/when I can:

io.reactivex.netty.protocol.http.client.HttpClientTest > testNonChunkingStream FAILED
    java.lang.ClassCastException

io.reactivex.netty.protocol.http.client.HttpClientTest > testChunkedStreaming FAILED
    java.lang.ClassCastException

io.reactivex.netty.protocol.http.client.HttpClientTest > testMultipleChunks FAILED
    java.lang.ClassCastException

io.reactivex.netty.protocol.http.client.HttpClientTest > testMultipleChunksWithTransformation FAILED
    java.lang.ClassCastException
        Caused by: rx.exceptions.OnErrorThrowable$OnNextValue

io.reactivex.netty.protocol.http.client.HttpRedirectTest > testRedirectWithConnPool FAILED
    java.util.concurrent.ExecutionException at HttpRedirectTest.java:161
        Caused by: java.util.NoSuchElementException

@NiteshKant
Copy link
Member

@alexwen I have created this PR #242 for the fix to send content onNext unconditionally. It was a little more involved than removing the if-check.

@NiteshKant
Copy link
Member

I am closing this PR in favor of #242, thanks for finding this out, anyways!

@NiteshKant NiteshKant closed this Oct 13, 2014
@alexwen
Copy link
Author

alexwen commented Oct 13, 2014

No problem. Glad to see there will be a fix soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants