Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-3296

URLHandlers caches null as values for common protocols

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • framework-3.0.8
    • framework-4.0.3
    • Framework
    • None

    Description

      A JBoss AS7 user has reported being unable to run the Apache Sling web app in AS 7. I determined that the issue is once org.apache.felix.framework.URLHandlers is installed as the JVM's URLStreamHandlerFactory, URLs with protocol "jar" can no longer be parsed.[1]

      Here's the problem. Line references are to [2]:

      1) The singleton of this URLHandlers class gets instantiated. It attempts to load and cache standard handlers for common protocols. At L148 it does this for "jar".

      2) At L353 it's trying to load one of the standard URLStreamHandler impls for the "jar" protocol, e.g. sun.net.www.protocol.jar.Handler. It uses Class.forName("sun.net.www.protocol.jar.Handler"). This fails (returns null) because the JBoss Modules module for this deployment does not have visibility to this class.

      3) At L367 it stores "null" for this protocol in its m_builtIn map under key "jar".

      4) Thereafter any call to createURLStreamHandler (L390) will call into getBuiltInStreamHandler (L413). That will return null because it will find the null in m_builtIn stored in step 3) above (L330 & L332).

      A fairly simple fix is to at L148 test the result of the getBuiltInStreamHandler call and if null remove the entry from m_builtIn. It should probably do the same kind of thing in the init(String) method (L120).

      An alternative is to do all the step 1) stuff between L142 and L148 after the try/catch block at L157. At that point a ref to the standard AS7 URLStreamHandlerFactory will be available in field m_streamHandlerFactory and can be used to load the standard handlers rather than relying on Class.forName.

      [1] http://lists.jboss.org/pipermail/jboss-as7-dev/2012-January/004956.html
      [2] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.framework/2.0.5/org/apache/felix/framework/URLHandlers.java

      Attachments

        1. FELIX-3296.patch
          9 kB
          Felix Meschberger
        2. FELIX-3296-2.patch
          9 kB
          Felix Meschberger

        Activity

          People

            karlpauls Karl Pauls
            bstansberry Brian Edward Stansberry
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: