-
Notifications
You must be signed in to change notification settings - Fork 34
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
RequestBuilderWrapper's url can get out of sync with the wrapped AsyncHttpClient.BoundRequestBuilder's url #56
Comments
I think I need to understand the use case. Are you trying to reuse a I don't know that I ever tested whether the underlying While you're at it, might as well do the same thing for method. Hmm, but what about the circuit breaker stuff? If you're changing URL/method, maybe you'd want to change the circuit breaker too? The more I think about this the more I dislike the use case - I think I'd just prefer these be treated as single-use builders. I'm not sure the extra code and complexity is worth it here. Eventually we'll be replacing all this stuff with a homerolled solution that supports any combination of streaming (chunked) or full request and response handling, and the clunkiness of |
After looking at both of them and coding up solutions, I also prefer option 1. The main use case I have is updating a URL after the RequestBuilderWrapper has been created. (request composer use case). I can take N number of inputs from a user and potentially replace bits in a url after I have created the RequestBuilderWrapper. I would ideally be updating a request and not creating a new one. In my case I could be replacing queryArgs or the path, depending on the inputs of the user in addition to setting headers or a body. The setUrl method of the BoundRequestBuilder handles both setting a url with query params or adding query params without issue as it would merge query params on the setUrl(String) in addition to the addQueryParam() methods as they were called on the builder. To solve my use case without changing the current Riposte code... If i call 'setUrl' on the BoundRequestBuilder I am able to update the Url and have everything work as expected, just the logging is not accurate and doesn't reflect reality of the actual calls. On updating the method on the builder...You cannot update the Method after you have created a BoundRequestBuilder as the builder is created with a given Method, but it does allow setting pretty much everything else after creation. Once you call the 'build' method then its final and you cannot change it anymore (signature calculator has run, etc). Until build is called you can add / modify the request (headers, body, query param, etc) without issue. Your circuit breaker point is a valid concern...but it is also an issue today since the two can get of sync (default circuit breaker based on the host inside the RequestBuildWrapper, which might not the value used to actually make the request). The circuit breaker comes into play when you actually go to execute the request, so providing a way to keep the Wrapper and BoundRequestBuilder in sync would prevent any issues with the circuit breaker. I know this is a long reply, and I hope I covered the main issues and questions you had. Let me know if you need some clarification or more details on anything. Also which way you are leaning (I should solve my issue in another way, or add a setUrl to the Wrapper) |
I guess I'm ok with doing this provided there's some relevant javadocs explaining what to do and what not to do. Seems like a reasonable stopgap until we provide our own client that doesn't require this builder-wrapper gunk. On setting the HTTP method - you are correct that you have to create a |
@nicmunroe It was my bad on reading the code. I was did not find it in the parent and didn't realize there was a setMethod on there. I knew the setUrl worked and was exposed from my testing and just was reading code around the setMethod. I'll go through and add two methods: |
fixed in 0.10.0 |
Summary of issue
If a user of RequestBuilderWrapper would change the underlining url inside the BoundRequestBuilder after they construct a RequestBuilderWrapper the two would get out of sync as the RequestBuilderWrapper's url is final but the BoundRequestBuilder allows the URL to be changed after initial creation.
This is an issue as the tracing started inside AsyncHttpClientHelper.executeAsyncHttpRequest reads the url it logs and passes around from the RequestBuilderWrapper due to not having a handle on the wrapped BoundRequestBuilder's values at the time before the request is made as they do not expose them.
Typical usage of the async client:
AsyncHttpClient.BoundRequestBuilder allows for the url to be set on it as such
builder.requestBuilder.setUrl("url");
This would bypass the RequestBuilderWrapper and the two values would no longer be in sync as the RequestBuilderWrapper's url is final and only set on creation of a RequestBuilderWrapper.
There is currently not an exposed way to update the URL of the RequestBuilderWrapper after it is created while maintaining the rest of the modified request.
Potential solution to this problem I thought about were:
The text was updated successfully, but these errors were encountered: