You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2022/02/01 06:22:11 UTC
[GitHub] [sling-org-apache-sling-rewriter] cziegeler commented on a change in pull request #5: SLING-11103 - Improvements in synchronization and additional logging …
cziegeler commented on a change in pull request #5:
URL: https://github.com/apache/sling-org-apache-sling-rewriter/pull/5#discussion_r796290518
##########
File path: src/main/java/org/apache/sling/rewriter/impl/TransformerFactoryServiceTracker.java
##########
@@ -46,7 +50,7 @@ private boolean isGlobal(final ServiceReference ref) {
private TransformerFactoryEntry[][] cached = EMPTY_DOUBLE_ENTRY_ARRAY;
/** flag for cache. */
- private boolean cacheIsValid = true;
+ private volatile boolean cacheIsValid = true;
Review comment:
I fear it is even more complicated than this; I looked at how the tracker works in more detail: the tracker updates its state *after* it returns from addingService, so within that method we have no chance to correctly invalidate the cache.
The service tracker has a tracking count (getTrackingCount()) - so instead of the boolean flag, we can store the last used tracking count in the get method and compare it with the current tracking count. If they differ, the cache needs updates. The minor downside is that the cache will also be changed if there was a change in non-global transformers, but that is neglectable.
--
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: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org