-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Add initialization of hints to request/response modification. #299
Conversation
@re6exp Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@@ -123,14 +124,14 @@ public GatewayFilterSpec hystrix(Consumer<HystrixGatewayFilterFactory.Config> co | |||
return filter(factory.apply(this.routeBuilder.getId(), configConsumer)); | |||
} | |||
|
|||
public <T, R> GatewayFilterSpec modifyRequestBody(Class<T> inClass, Class<R> outClass, RewriteFunction<T, R> rewriteFunction) { | |||
public <T, R> GatewayFilterSpec modifyRequestBody(Class<T> inClass, Class<R> outClass, RewriteFunction<T, R> rewriteFunction, Map<String, Object> inHints, Map<String, Object> outHints) { |
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.
Since RC1 is already public, let's leave the original methods and either overload, or create a spec.
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.
Don't worry about RC1, just keep the originals and either overload or create a spec similar to what is in your branch.
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.
So, I'll overload methods with specs. Is it OK? If yes, tomorrow I'll send you PR to master branch, keeping existed signatures as they were before.
OK, tomorrow I am going to review what you write here... It's late (Moscow time 10 p.m.), I'm pretty tired and I'm going to go to bed.
Tomorrow is fine |
…xisting signature.
@re6exp Thank you for signing the Contributor License Agreement! |
@spencergibb
|
I've fixed some issues with response body modification. Tests covering response body modification were copied from my old branch with some modification. They work. With BUT tests for |
…galStateException in RewriteUtils.
rebuilding |
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 few comments
spring-cloud-gateway-core/pom.xml
Outdated
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-web</artifactId> | ||
<version>5.0.6.BUILD-SNAPSHOT</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.
This is bad. This should already be a dependency.
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.
Prior version doesn't work. I wrote comments here and in old issues.
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.
rebase, and you won't need this anymore.
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.
Glad to hear that!
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.
Removed (by my side - not committed yet).
* | ||
*/ | ||
@Configuration | ||
@EnableWebFlux |
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.
This is autoconfigured by boot.
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.
in other words, it shouldn't be needed here, just WebFluxConfigurer
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.
Ok
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.
Removed.
@@ -37,7 +40,7 @@ | |||
|
|||
import static org.springframework.cloud.gateway.filter.factory.rewrite.RewriteUtils.process; | |||
|
|||
public class ModifyRequestBodyGatewayFilterFactory | |||
public class ModifyRequestBodyGatewayFilterFactory<T, R> |
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 don't think these generics make sense here.
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.
When user writes code it helps him.
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.
As I understand, old code will work too.
Build is timing out
|
Hm, it worked... 22 days ago. UPD: code worked - I add local snapshot to my app, it works. |
The main problem for me was request modification tests. They were being terminated abnormally. So, Spencer, should I change smth you wrote about, and commit one more time, or you plan to do by yourself? |
I can do it tomorrow. |
Tests for response body modification run perfectly - thx to Rossen, he fixed problem with sse serialization in v. 5.0.6 which has been released some time ago. But Time out while running
This blocks any changes I made in this PR. |
I've only had a very brief look, but The error message is referring to a Spring Framework class, the |
So, this leads to when I run tests, they can't be successfully finished, do I understand right? Reading the body cause to blocking operation, which is disallowed (so isTerminated() check returns false) and leads junit tests to crash... Do I understand your comment correct? There is an example of a gateway application, which somehow can be executed and uses I can assume it my fault, but this code works with another API and should, in principle, working here too. |
The body may not be read immediately, so the isTerminated check makes no sense. It cannot be guaranteed to return true. |
And in case of using junits it crashs. As I guessed... |
No description provided.