spring-cloud / spring-cloud/spring-cloud-gateway
Field routesToCache inner class AdaptCachedBodyGlobalFilter maybe should be modified
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
Describe.
I noticed that it's a good way to use AdaptCachedBodyGlobalFilter to cache request body in the scenario of reuse.And I see it listening a EnableBodyCachingEvent event to judge whether or not to cache the request body.As a result, the field routesToCache will only have the entries with true value.I also notice the RetryGatewayFilterFactory use the event.Once I configure the routes with retry filter, the route will have the feature with caching request body permanently.I can't stop the behavior by revise the configuration in configuration center which support hot loading by refreshing routes.
private ConcurrentMap<String, Boolean> routesToCache = new ConcurrentHashMap<>();
@Override
public void onApplicationEvent(EnableBodyCachingEvent event) {
this.routesToCache.putIfAbsent(event.getRouteId(), true);
}
Describe the solution you'd like
I think AdaptCachedBodyGlobalFilter should support one more event such as DisableBodyCachingEvent to set/delete the entry in routesToCache.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading AdaptCachedBodyGlobalFilter, especially routesToCache and its EnableBodyCachingEvent handling, then trace how RetryGatewayFilterFactory triggers that event. Check the route refresh path and existing event flow to determine how caching should be disabled or removed. Done means refreshed routes no longer retain request-body caching after the retry configuration is removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100