Skip to content

Conversation

zxw1962
Copy link
Contributor

@zxw1962 zxw1962 commented Aug 18, 2014

  1. fix typo of omit;
  2. change param name from "value" to a meaningful "sync";
  3. seems obtainMessage can be refined as one line;

msg = Message.obtain(handler, responseMessageId, responseMessageData);
}
return msg;
return Message.obtain(handler, responseMessageId, responseMessageData);
Copy link
Contributor

Choose a reason for hiding this comment

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

@zxw1962
This is wrong as handler could be null. The alternative when that happens is meant to emulate a Message.obtain(), so the entire method has to stay as-is.

Copy link
Member

Choose a reason for hiding this comment

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

@zxw1962 yes, sincerely this is invalid change, we have to support different scenarios, and this is key component that was written like this for that purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fineswap @smarek why handler is null need to be handled differently? for me, Message.obtain() call is the same as Message.obtain(null, what, obj), isn't it? so, we don't have to test for null, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

@zxw1962

This is correct now, but what happens in the future if the underlying implementation changes and a check for null is introduced to Message.obtain()? (by the Android team, or any other manufacturer -- Nokia X, Sony, Samsund, htc, etc. -- who goes in and changes the source code to their satisfaction.)

Potentially, this will make all apps relying on AHC to fail if the device is upgraded to run a newer Android (with a different implementation for Message.obtain()).

We have to consider that this library is used by thousands of apps and we have to rely on backward-compatibility even if leaving some useless (currently) code around.

Copy link
Member

Choose a reason for hiding this comment

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

@fineswap future changes to this API is unlikely, as this is stable behavior since API v1
@zxw1962 I'm sorry, I've gone too quickly through implementation of Message API, this is correct change, as the [Message.obtain(Handler,int,Object)](https://developer.android.com/reference/android/os/Message.html#obtain%28android.os.Handler, int, java.lang.Object%29) just sets passed values into internal fields of Message. I'm pulling back my previous complaints.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so what should I do, revert or just leave it as it is?

Copy link
Member

Choose a reason for hiding this comment

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

Leave it, I approve the change, it's correct, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks, will update others soon...

@fineswap
Copy link
Contributor

Otherwise, this is a honorable pull request and I'll be happy to merge it once these 2 points are taken care of, @zxw1962.

@fineswap fineswap added this to the 1.4.6 milestone Aug 18, 2014
@fineswap fineswap self-assigned this Aug 18, 2014
@zxw1962
Copy link
Contributor Author

zxw1962 commented Aug 18, 2014

@fineswap @smarek I'm a fresh man here, so what's next? should i squash them to one commit? Just let me know if there's anything needed to do...

@smarek
Copy link
Member

smarek commented Aug 18, 2014

@zxw1962 Nope, not needed, just last checks before merging it.
@fineswap what do you think ?

@zxw1962
Copy link
Contributor Author

zxw1962 commented Aug 18, 2014

@smarek should i merge these to upstream or you guys will take care of that?

@smarek
Copy link
Member

smarek commented Aug 18, 2014

@zxw1962 you can't merge it yourself, we'll do it, give it a time, I'm waiting for cross-review from @fineswap

@zxw1962
Copy link
Contributor Author

zxw1962 commented Aug 18, 2014

nice, good to know.

@fineswap
Copy link
Contributor

@smarek @zxw1962
Except for the 2 points which I pointed in the beginning, the rest seems great. Of these 2 points, the assert is more needed, however, as the Message.obtain() is not a show stopper.

@smarek
Copy link
Member

smarek commented Aug 18, 2014

Good, merging it then.

smarek added a commit that referenced this pull request Aug 18, 2014
Fix comments typo, rename param, refine obtainMessage
@smarek smarek merged commit 534a057 into android-async-http:master Aug 18, 2014
@smarek
Copy link
Member

smarek commented Aug 18, 2014

@zxw1962 thanks for the contribution and patience :-)

@zxw1962
Copy link
Contributor Author

zxw1962 commented Aug 19, 2014

@smarek @fineswap my pleasure :-)

@zxw1962
Copy link
Contributor Author

zxw1962 commented Aug 19, 2014

@smarek @fineswap I have some small ideas about the current code, so should i just directly pull a request(I'm not sure it is right) or maybe chat with each other on IM tools firstly? Please point me, thanks in advance!

@fineswap
Copy link
Contributor

@zxw1962
Just create a new pull request and we can discuss it right in here (so history is preserved, too).

@smarek
Copy link
Member

smarek commented Aug 20, 2014

@zxw1962 there are two options

  • Raise new issue, and we can discuss your idea before commiting effort to implement it
  • Offer us Pull Request, and we can talk about it afterwards (as we did here)

Second option is more uncertain, as you can't be sure what will and won't be merged, so if I were you, I'd stick with first option.

@zxw1962
Copy link
Contributor Author

zxw1962 commented Aug 20, 2014

@smarek big thanks, really appreciate.

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

Successfully merging this pull request may close these issues.

3 participants