You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by GitBox <gi...@apache.org> on 2022/07/09 09:00:25 UTC

[GitHub] [cayenne] andrus commented on a diff in pull request #510: CAY-2748 Mutating the list returned from the local query cache changes the cache

andrus commented on code in PR #510:
URL: https://github.com/apache/cayenne/pull/510#discussion_r917244986


##########
cayenne-server/src/main/java/org/apache/cayenne/util/ObjectContextQueryAction.java:
##########
@@ -369,7 +370,21 @@ protected boolean interceptLocalCache() {
             // response may already be initialized by the factory above ... it is null if
             // there was a preexisting cache entry
             if (response == null) {
-                response = new ListResponse(cachedResults);
+                response = new ListResponse(cachedResults != null ? Collections.unmodifiableList(cachedResults) : null); // make a defensive copy avoid leaking cache internal data

Review Comment:
   I think we should store an immutable list in the cache, not wrpa it when we retrieve it. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cayenne.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org