-
Notifications
You must be signed in to change notification settings - Fork 37.7k
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
Support store-by-value in ConcurrentMapCacheManager [SPR-13758] #18331
Comments
Juergen Hoeller commented We're currently caching the result as-is. If your code decides to modify a returned collection there, it essentially breaks the That said, we could change that contract to always return a copy of the collection from any In any case, this looks like a limitation of the current caching contract that you're violating through an explicit Juergen |
member sound commented Ok, then indeed I might have misunderstood the So you're right, I expected a copy of the list. |
Stéphane Nicoll commented I don't think it's a good idea that The actual issue is not in There is no bug here IMO and I'd be tempted to close it but we could also offer an option to serialize data in |
Juergen Hoeller commented Good point, it's actually a consequence of serializing a value versus storing it as-is and therefore dependent on the cache provider. Semantically, I'm not sure it's ever a good idea to modify a value returned from a cacheable method... But indeed, a store-by-value mode in Juergen |
Stéphane Nicoll commented
|
member sound opened SPR-13758 and commented
If you run the following code, the
@Cachable
method will not always return the same results (but it should).Steps to reproduce the error: run http://localhost:8080/rest/test
I noticed that if I use a
@PostConstruct
method running the controller.test() method twice, this would not cause the error. So the application starts up fine, but invoking the servlet explicit triggers the failure.Affects: 4.2.3
Issue Links:
Referenced from: commits cf20308, 0194988
The text was updated successfully, but these errors were encountered: