Skip to content

BinaryHttpResponseHandler.java: handleMessage cast eror on FAILURE_MESSAGE management #198

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

Merged
merged 2 commits into from
Mar 27, 2013

Conversation

lucamac
Copy link
Contributor

@lucamac lucamac commented Mar 27, 2013

Hi loopj,
in BinaryHttpResponseHandler there seems to be an invalid cast when a byte array is sent as second parameter to handleFailureMessage(), while a String is expected and a string is actually received in that case in msg.obj.response[1].

Thanks, and keep up the good work
Luca

loopj added a commit that referenced this pull request Mar 27, 2013
BinaryHttpResponseHandler.java: handleMessage cast eror on FAILURE_MESSAGE management
@loopj loopj merged commit c8cfff9 into android-async-http:master Mar 27, 2013
@loopj
Copy link
Collaborator

loopj commented Mar 27, 2013

Thanks @lucamac

@mattspitz
Copy link

As a side note, I upgraded to this patch (thanks!) and my BinaryResponseHttpHandlers totally failed.

I'd overridden onFailure(Throwable, byte[]), which was originally called before this patch, and it never ended up getting called because this new method now calls the superclass's onFailure(Throwable, String).

I see now that the onFailure(Throwable, byte[]) is deprecated, but as far as I know, overriding a deprecated method doesn't cause a compiler warning. Hence, when I upgraded, I was rather surprised. Can we just remove onFailure(Throwable, byte[]) entirely if it's never going to get called? I think that'd be less of a pain than having everyone find out on their own that their handler isn't getting called.

Thanks again for the library and the fix!

@rishabhmhjn
Copy link
Contributor

I had got NullPointerException on that line, maybe because in some cases, response[1] is null!
I am yet to replicate the situation but it did happen!

@mattspitz
Copy link

Oh, I agree. I was getting that error, too, and the patch does fix it.

My point is that the fix calls a different error handling method than it did before, which was very unexpected for me as an end-user.

@rishabhmhjn
Copy link
Contributor

I think it won't solve the problem, since response[1] is null and doing a response[1].toString() will also result in a NullPointerException. Isn't it?

@mattspitz
Copy link

I'm not sure what you're saying. I agree that this patch is necessary to avoid the NPE.

What I'm saying is that it now silently calls a different handler that the programmer may not have written (and has no reason to believe that he should have written), which is rather confusing.

@rishabhmhjn
Copy link
Contributor

AH! I got what you said. I agree that there should have been a mention about the handleFailureMessage(...) call change. :)

I saw this patch just now and realized that, this patch might not be the solution to the original problem! And it might persist.

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.

4 participants