Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-7883

Remove references to Thread#getContextClassLoader() from Lucene/Solr codebase

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      As discussed in LUCENE-7873, the use of Thread.currentThread().getContextClassLoader() is in most cases a bug caused by sloppy usage of ClassLoader APIs and should be replaced by getClass().getClassLoader().

      In Lucene we only have the ClassPathResourceLoader, but this one can be solved by removing the "default" constructor. It only affects CustomAnalyzer, that should also be extended in Lucene 7.

      The uses in Solr and its test are all to be replaced by getClass().getClassLoader() (except some workaround with clustering using a try-finally). This is in most cases historical code, when Solr was a web application to workaround some buggy webapp containers. In the current state, the code is "just wrong".

      Finally, we should add java.lang.Thread#getContextClassLoader() to forbidden-apis.

      I'd like to get this into Lucene 7, as it affects some APIs in Lucene.

        Attachments

        1. LUCENE-7883.patch
          24 kB
          Uwe Schindler

          Issue Links

            Activity

              People

              • Assignee:
                uschindler Uwe Schindler
                Reporter:
                uschindler Uwe Schindler
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: