dsmiley commented on code in PR #3185:
URL: https://github.com/apache/solr/pull/3185#discussion_r1958519813


##########
solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java:
##########
@@ -391,25 +393,22 @@ public boolean exists(String path) throws IOException {
   public final Directory get(String path, DirContext dirContext, String 
rawLockType)
       throws IOException {
     String fullPath = normalize(path);
+    Directory directory;
+    CacheValue cacheValue;
     synchronized (this) {
       if (closed) {
         throw new AlreadyClosedException("Already closed");
       }
 
-      final CacheValue cacheValue = byPathCache.get(fullPath);
-      Directory directory = null;
-      if (cacheValue != null) {
-        directory = cacheValue.directory;
-      }
-
-      if (directory == null) {
+      cacheValue = byPathCache.get(fullPath);
+      if (cacheValue == null) {
         directory = create(fullPath, createLockFactory(rawLockType), 
dirContext);

Review Comment:
   Indeed it's valid for a DirectoryFactory to potentially customize the 
Directory for use.  But it's wrong to do that *here*, as it's basically a bug 
in which the first DirContext will "win" and have it be cached; not later 
DirContext needs.  This is a bug for HdfsDirectory but the fix is in the design 
of CachingDirectoryFactory.  *Instead*, the filter method you added should be 
overwritten so that the DirectoryFactory can tweak the response for the 
DirContext.  For Hdfs, that would be unwrapping BlockCache for anything but 
DEFAULT.  Note HdfsDirectory was removed yesterday.



-- 
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: issues-unsubscr...@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to