Repository navigation
Conversation
…ctor`. This allows `GitHubClient` to become final. `GitHubHttpUrlConnectionClient` is now just an implementation of `ResponseConnector` which delegates to `HttpConnector`, which allows everything based on `HttpConnector` to keep working.
|
Okay, this is embarrassing, but I'm working on basically the same change. I haven't looked at your change in any depth, but the description sounds much the same. I'll get you feedback shortly. |
Codecov Report
@@ Coverage Diff @@
## main #1287 +/- ##
============================================
- Coverage 77.50% 77.30% -0.20%
- Complexity 1905 1920 +15
============================================
Files 189 191 +2
Lines 6000 6055 +55
Branches 328 336 +8
============================================
+ Hits 4650 4681 +31
- Misses 1150 1166 +16
- Partials 200 208 +8
Continue to review full report at Codecov.
|
|
Lol! Well feel free to dump this PR and just merge yours :) All I care about is that I can do something like |
|
@nedtwigg Would you be willing to review #1290 ? It should look very familiar. 😄 |
|
Absolutely! Review incoming. |
| protected ResponseInfo getResponseInfo(GitHubRequest request) throws IOException { | ||
| return connector.getResponseInfo(request, authorizationProvider); | ||
| } |
There was a problem hiding this comment.
I chose to treat the request as unmodifiable, whereas your GitHubClient has private GitHubRequest prepareRequest(GitHubRequest request) throws IOException {. In that method you add the auth headers, and also do some accept/encoding stuff that I don't understand very well. Probably my PR is just plain missing those features.
I think this way of handling authorization by passing the provider vs modifying the request is the only substantive difference between the two PRs, and I like your way better.
|
I like yours better :) Closing as dupe, looking forward to the next release with the new features. |
Requests are immutable, this creates a new request. I'll change the name of the method. |
|
Fwiw I think your name |
This PR touches a lot of files, but it's pretty straightforward. The commits tell the story as simply as I can tell it, every commit in the chain passes
mvn test. It resolves #1085 in a backward-compatible way (along with #1262 and #754).It introduces a new interface
ResponseConnector, with just a single method which functions as a delegate to thegetResponseInfomethod ofGitHubClientwhich allowsGitHubClientto be become final.github-api/src/main/java/org/kohsuke/github/GitHubClient.java
Lines 403 to 406 in 7a91e43
GitHubHttpUrlConnectionClientnow implementsResponseConnectorrather thanGitHubClient. This means that all of the oldHttpConnectorstuff can keep working transparently:github-api/src/main/java/org/kohsuke/github/GitHubClient.java
Lines 137 to 143 in 7a91e43
In order to make it possible to implement
ResponseConnector, I had to extractResponseInfointo its own class and make it and some of its members public. Most of the commits in this PR are pure refactors (refactor commits aren't mixed in with new or changed functionality) so you can see exactly which parts had to become public.The whole point of the PR is to bypass
HttpConnectorand users can now swap the newOkHttpResponseConnectorinstead of (OkHttpConnector+GitHubHttpUrlConnectionClient).I believe the only breaking change in this PR is to
[Abuse/Rate]LimitHandler, but it's a transparent change to all users who are using the built-in policies, and an easy change for users who aren't. The new names in the PR aren't great (e.g.ResponseInfo,ResponseConnector) but I just kept all names to match their name from where they were refactored from. I didn't mark any of the older stuff as deprecated.One path forward might be to:
HttpConnectorand all its usages