rombert commented on a change in pull request #5: SLING-7544 - improving 
optimized alias lookup to not block during int…
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/5#discussion_r182655798
 
 

 ##########
 File path: 
src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
 ##########
 @@ -128,9 +133,9 @@
 
     private Map <String,List <String>> vanityTargets;
 
-    private volatile Map<String, Map<String, String>> aliasMap;
+    private Map<String, Map<String, String>> aliasMap;
     
-       private volatile boolean isAliasMapInitialized = false;
+       private boolean isAliasMapInitialized = false;
 
 Review comment:
   The changes you made don't ensure that the values are changed atomically. 
Assuming that we have thread `T1` updating the values and thread `T2` reading 
the values it's possible for thread `T1` to set value 1, then `T2` to read 
value 1 (new) and value 2 (old).
   
   You should ensure that the values are changed atomically, for instance by 
using synchronized blocks or by using a single volatile field that holds both 
the aliasMap data and the init ready flag.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to