madrob commented on a change in pull request #1358: SOLR-14256: replaced EMPTY 
with empty() to fix deadlock
URL: https://github.com/apache/lucene-solr/pull/1358#discussion_r394057677
 
 

 ##########
 File path: solr/core/src/java/org/apache/solr/search/DocSet.java
 ##########
 @@ -36,6 +36,21 @@
     assert this instanceof BitDocSet || this instanceof SortedIntDocSet;
   }
 
+  // we can't simply use a trivial static initializer "= new SortedIntDocSet" 
because it can lead to classloader deadlock
+  private static DocSet EMPTY;
+
+  /** An empty instance. */
+  public static DocSet empty() {
 
 Review comment:
   If you do the singleton holder idiom then you don't need to have a null 
check (at the cost of an extra class, but the VM takes care of this quickly) 
[Effective Java 3rd Ed, Item 83] 
   
   ```
       private static class LazyHolder {
           static final DocSet INSTANCE = new SortedIntDocSet(new int[0]);
       }
   
       public static DocSet empty() {
           return LazyHolder.INSTANCE;
       }
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to