-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Added retrofit2 module. #1419
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
Added retrofit2 module. #1419
Conversation
|
Seems like unrelated tests are failing. |
Thanks! Being curious, why do you use AHC with Retrofit? I mean I would expect anyone going with Retrofit to go with the full Square stack and use OkHttp instead.
Correct me if I'm wrong, but such code generation causes stacktraces to not be aligned with source code lines, right? Also, my concern is that contributors might think this is code generation fiesta time, eg why not vavr (ex javaslang) or something else.
Yeah, that's #1380. |
| private void throwAlreadyExecuted() { | ||
| throw new IllegalStateException("This call has already been executed."); | ||
| } | ||
| } No newline at end of file |
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.
missing line feed
| .request(request) | ||
| .build(); | ||
| } | ||
| } No newline at end of file |
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.
missing line feed
| }; | ||
| } | ||
|
|
||
| } No newline at end of file |
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.
missing line feed
| return e -> { | ||
| }; | ||
| } | ||
|
|
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.
kill empty line
| private void doThrow(String message) { | ||
| throw new RuntimeException(message); | ||
| } | ||
| } No newline at end of file |
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.
missing line feed
| .build(); | ||
|
|
||
| // then | ||
| Assert.assertTrue(factory.getHttpClient() == httpClient); |
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.
Use Assert static imports
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.
Use assertEquals (everywhere it makes sense)
| httpClient.close(); | ||
| } | ||
|
|
||
| @Test(enabled = false) |
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.
Why are all the tests in this class disabled?
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.
They're using Github API, which is rate-limited and github may not be up all the time. Do you want me to convert this test so that it would start wiremock or similar webserver on local host and perform http calls against it?
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.
Got it. Please have a look at the org.asynchttpclient.testserver package. Then, we might need some maven build refactoring to the test jar is visible from extra modules.
|
|
||
| <properties> | ||
| <retrofit2.version>2.3.0</retrofit2.version> | ||
| <lombok.version>1.16.16</lombok.version> |
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.
Actually, I'd rather not use lombok in there so coding style is consistent.
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.
I can convert all the code to normal java code, but frankly i don't think it's worth it - some other open source projects, namely spring-cloud started using lombok 2-3 years ago and it seem to work for them very well.
So, do you want me to de-lombok the code?
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.
You can leave Lombok there. But I don't think it will ever make it into main module.
I find AHC most configurable http client in java world. I really like the idea of sharing single event loop group between differently configured AHC client instances, i really like it's non-blocking API and websocket support. I don't find OKHttp as configurable and i really don't like it's async api. But i really do like the idea of retrofit - and i would like to use proven http client engine beneath it.
Lombok generates java code at compile time, so there is no runtime performance penalty. Stack trace line numbers may differ only with I use lombok daily and find it super-stable and useful. If you want me to remove lombok, that's fine with me, but i really don't think it's worth rejecting it. |
|
Ok, @slandelle i've addressed all your code review comments and added the following functionality:
Please review again. If you're okay with it, i will squash everything into one commit and resubmit. |
|
Thanks! Note that I fixed a NPE issue (see next commit). Cheers! |
|
Whoa! Thanks for cooperation! :-) |
This PR adds Retrofit2 async-http-client extras module.
Project Lombok is used to evade boilerplate.