Lucene - Core
  1. Lucene - Core
  2. LUCENE-6921

Fix SPIClassIterator#isParentClassLoader to don't require extra permissions

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.5, 6.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      This is not really a big issue, because most setups use a "good" context classloader. The context classloader is required by the Java ServiceProvider standard to look for META-INF classes. To work around issues in some setups, the analysis and codec SPIs also scan our own classloader, if it is not a parent of the context one. This check requires permissions, if we are not a parent.

      This will fix the parent check to simply return false (and enforce classpath rescan) if we don't have enough permissions. This is the right thing to do, because if we have no permissions, we are also not a parent!

      1. LUCENE-6921.patch
        6 kB
        Uwe Schindler
      2. LUCENE-6921.patch
        3 kB
        Uwe Schindler
      3. LUCENE-6921-fix.patch
        2 kB
        Uwe Schindler

        Activity

        Hide
        Uwe Schindler added a comment -

        Patch. I also removed support for null classloader (makes no sense for Lucene, this is only required inside the JDK).

        Show
        Uwe Schindler added a comment - Patch. I also removed support for null classloader (makes no sense for Lucene, this is only required inside the JDK).
        Hide
        Uwe Schindler added a comment -

        Add a test and shortcut the check to don't use AccessController if not needed.

        Show
        Uwe Schindler added a comment - Add a test and shortcut the check to don't use AccessController if not needed.
        Hide
        ASF subversion and git services added a comment -

        Commit 1718078 from Uwe Schindler in branch 'dev/trunk'
        [ https://svn.apache.org/r1718078 ]

        LUCENE-6921: Fix SPIClassIterator#isParentClassLoader to don't require extra permissions

        Show
        ASF subversion and git services added a comment - Commit 1718078 from Uwe Schindler in branch 'dev/trunk' [ https://svn.apache.org/r1718078 ] LUCENE-6921 : Fix SPIClassIterator#isParentClassLoader to don't require extra permissions
        Hide
        ASF subversion and git services added a comment -

        Commit 1718079 from Uwe Schindler in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1718079 ]

        Merged revision(s) 1718078 from lucene/dev/trunk:
        LUCENE-6921: Fix SPIClassIterator#isParentClassLoader to don't require extra permissions

        Show
        ASF subversion and git services added a comment - Commit 1718079 from Uwe Schindler in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1718079 ] Merged revision(s) 1718078 from lucene/dev/trunk: LUCENE-6921 : Fix SPIClassIterator#isParentClassLoader to don't require extra permissions
        Hide
        Uwe Schindler added a comment -

        Committed.

        Show
        Uwe Schindler added a comment - Committed.
        Hide
        Uwe Schindler added a comment -

        I reopening:
        The doPrivileged check is inapprop, because the caller's classloader is inspected and not our own. So the caller must have permission.

        For Lucene this is no problem, because the caller is responsible for class loaders he creates.

        I will remove the doPrivileged check in the SPI check.

        Show
        Uwe Schindler added a comment - I reopening: The doPrivileged check is inapprop, because the caller's classloader is inspected and not our own. So the caller must have permission. For Lucene this is no problem, because the caller is responsible for class loaders he creates. I will remove the doPrivileged check in the SPI check.
        Hide
        Uwe Schindler added a comment -

        Fix.

        Show
        Uwe Schindler added a comment - Fix.
        Hide
        Uwe Schindler added a comment -

        Just to mention: This is all fine, because static initializers may never break, because the security exception is catched and use to "answer the parent question".

        Show
        Uwe Schindler added a comment - Just to mention: This is all fine, because static initializers may never break, because the security exception is catched and use to "answer the parent question".
        Hide
        ASF subversion and git services added a comment -

        Commit 1718082 from Uwe Schindler in branch 'dev/trunk'
        [ https://svn.apache.org/r1718082 ]

        LUCENE-6921: Remove not necessary doPrivilegedCheck and update docs.

        Show
        ASF subversion and git services added a comment - Commit 1718082 from Uwe Schindler in branch 'dev/trunk' [ https://svn.apache.org/r1718082 ] LUCENE-6921 : Remove not necessary doPrivilegedCheck and update docs.
        Hide
        ASF subversion and git services added a comment -

        Commit 1718083 from Uwe Schindler in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1718083 ]

        Merged revision(s) 1718082 from lucene/dev/trunk:
        LUCENE-6921: Remove not necessary doPrivilegedCheck and update docs.

        Show
        ASF subversion and git services added a comment - Commit 1718083 from Uwe Schindler in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1718083 ] Merged revision(s) 1718082 from lucene/dev/trunk: LUCENE-6921 : Remove not necessary doPrivilegedCheck and update docs.
        Hide
        Uwe Schindler added a comment -

        Committed. Sorry for trouble

        Show
        Uwe Schindler added a comment - Committed. Sorry for trouble
        Hide
        ASF subversion and git services added a comment -

        Commit 1718113 from Uwe Schindler in branch 'dev/trunk'
        [ https://svn.apache.org/r1718113 ]

        LUCENE-6921: Prevent NPE if stupid context classloader is null

        Show
        ASF subversion and git services added a comment - Commit 1718113 from Uwe Schindler in branch 'dev/trunk' [ https://svn.apache.org/r1718113 ] LUCENE-6921 : Prevent NPE if stupid context classloader is null
        Hide
        ASF subversion and git services added a comment -

        Commit 1718114 from Uwe Schindler in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1718114 ]

        Merged revision(s) 1718113 from lucene/dev/trunk:
        LUCENE-6921: Prevent NPE if stupid context classloader is null

        Show
        ASF subversion and git services added a comment - Commit 1718114 from Uwe Schindler in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1718114 ] Merged revision(s) 1718113 from lucene/dev/trunk: LUCENE-6921 : Prevent NPE if stupid context classloader is null

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development