-
Notifications
You must be signed in to change notification settings - Fork 97
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
Replace IO layer to use Apache HC + trivial cleanups #390
Conversation
Hi @slisaasquatch. Great to see another contribution! Due to the size and nature of this PR, I'm going to bring it to the team for review. I'll circle back with questions as they arise. |
Hi @slisaasquatch. We ran integration tests on your PR and found one test failing, pertaining to
In
The resulting URL constructed is now There are other instances where this solution can be applied that the integration tests don't catch, e.g. |
Yep, the issue makes sense. I just pushed the fix for |
@slisaasquatch Thanks for taking the time to do this and contribute it back! As you might know, we've put all our modernization efforts into our new and official Java library but we still intend to support our customers on this library for as long as possible. So, we're trying to be as conservative as possible with this library as it is heavily used in our customers' legacy systems. Having said that, I think this is a positive change and worth the risks associated. I appreciate that you've attempted to make it backwards compatible (on an API level). We've prodded this enough to have the confidence to say that that effort was successful. Still, I have some questions about the upgrade process for our other users. I practiced an upgrade locally and all seemed to go well, but do you think this will require any special instructions for people who may use a shaded version of the jar? Or possible conflicts with other dependencies? Let us know if there is anything else we can test out to get some more confidence. We're admittedly a little unsure about all the possible ways this may be getting used in the wild. |
I think it should be a seamless upgrade for most people, unless they use the ning AHC transitive dependency, in which case they just need to include it explicitly. I think shading will only make a difference for people that are incorrectly using the shaded dependency introduced by libraries that depend on this library. |
Good to hear! Should be smooth then.
Good callout, but that consequence should be acceptable. We don't support using this API from mobile anyway. |
As you probably know, I've created a few smaller pull requests in the past, and those were actually brought over from my fork, which is what we use today on production at SaaSquatch.
The pull request you see here represents the entirety of my fork, which is at this moment up and running on SaaSquatch servers, and has been battle tested for over a year without any issue.
While my previous smaller pull requests mainly focus on fixing obvious bugs and issues, this large pull request mainly aims to "modernize" this library to make it work well on a modern environment, as well as to make some minor improvements.
Here are some key points:
QueryParams
class right now is building parameters by manually concatenating Strings without any kind of URL encoding.URLEncodedUtils
from Apache HC solves exactly that.InputStream
s returned are in-memoryByteArrayInputStream
s. This is one of the quirks of AHC, as well as a number of other non-blocking Netty based HTTP clients. Apache HC supports streaming InputStreams, but I'm arbitrarily buffering it in memory to replicate the old behavior.DataTypeConverter
, which can cause problems with Java 9+.QueryParams
now uses a proper library to generate query parameters.Charsets.UTF_8
.HttpHeaders
.validateHost
method was scattered all over the place. Now it's only called in one place.validHosts
List
has been replaced with aSet
, which should be much faster at doingcontains
.XmlMapper
inRecurlyObject
, and it's used byRecurlyClient
andNotification
. There are alreadyTODO
comments for it, and it actually supports our use case at SaaSquatch. We need to be able to create "lightweight"RecurlyClient
s to use multiple API keys. ThecreateHttpClient
method can already be overridden so I can already use a shared instance of the HTTP client, theXmlMapper
is just the next and final thing that prevents us from creating a "lightweight"RecurlyClient
.RecurlyClient
. I do agree that those changes were finicky and hard to verify. I do not believe that this pull request has those problems.If you have any questions or suggestions, please don't hesitate to ask.
Thanks!