ServiceMix 4
  1. ServiceMix 4
  2. SMX4-1382

URL.equals() causes massive delay for shutdown of a Locator-enabled bundle

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: specs-2.5.0
    • Component/s: None
    • Labels:
    • Environment:

      Win7 64bit, Oracle JVM 6.0_29 64bit, Apache Felix 3.0.9

      Description

      While it seemed ok for quite a while, the shutdown of some locator-enabled spec bundles is suddenly starting to be delayed by up to a minute due to a call to URL.equals(). I don't know what exactly changed that the problem only shows up now. I've been running IPv6 on my network for a while. Please check out the following stack trace:

      java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
      java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:849)
      java.net.InetAddress.getAddressFromNameService(InetAddress.java:1202)
      java.net.InetAddress.getAllByName0(InetAddress.java:1153)
      java.net.InetAddress.getAllByName(InetAddress.java:1083)
      java.net.InetAddress.getAllByName(InetAddress.java:1019)
      java.net.InetAddress.getByName(InetAddress.java:969)
      java.net.URLStreamHandler.getHostAddress(URLStreamHandler.java:420)

      • locked org.apache.felix.framework.URLHandlersBundleStreamHandler@37447f2f
        java.net.URLStreamHandler.hostsEqual(URLStreamHandler.java:440)
        java.net.URLStreamHandler.sameFile(URLStreamHandler.java:396)
        java.net.URLStreamHandler.equals(URLStreamHandler.java:316)
        java.net.URL.equals(URL.java:842)
        org.apache.servicemix.specs.locator.Activator$BundleFactoryLoader.equals(Activator.java:172)
        java.util.ArrayList.remove(ArrayList.java:423)
        org.apache.servicemix.specs.locator.OsgiLocator.unregister(OsgiLocator.java:38)
      • locked java.lang.Class@7d4966cc
        org.apache.servicemix.specs.locator.Activator.unregister(Activator.java:126)
        org.apache.servicemix.specs.locator.Activator.stop(Activator.java:80)
      • locked org.apache.servicemix.specs.locator.Activator@585c718f
        org.apache.felix.framework.util.SecureAction.stopActivator(SecureAction.java:651)
        org.apache.felix.framework.Felix.stopBundle(Felix.java:2216)
        org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1192)
        org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
        java.lang.Thread.run(Thread.java:662)

      lookupAllHostAddr() is what appears to take up so much time. BundleFactoryLoader uses a java.net.URL to find out if two instances are equal. But URL.equals() can have serious side-effects as can be seen here. I think the easiest solution is to store a java.net.URI instead of a java.net.URL in BundleFactoryLoader (i.e. call u.toURI()) and do the comparison with that. Or just use the URLs toExternalForm(), i.e. a String. See also: http://javaantipatterns.wordpress.com/2007/11/24/comparing-urls-with-urlequals/

      Code in question:
      http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/Activator.java?view=annotate
      Apparently, the locator is used in various spec bundles (I'm running the JAXB and STAX API bundles).

      Incidentally, I first stumbled over the same problem with Jersey 1.5. It appears to use the exact same code as SMX4. (http://java.net/jira/browse/JERSEY-1006)

        Activity

        Hide
        Gert Vanthienen added a comment -

        Moved this over from the SM project - it's related to ServiceMix Specs.

        Show
        Gert Vanthienen added a comment - Moved this over from the SM project - it's related to ServiceMix Specs.

          People

          • Assignee:
            Unassigned
            Reporter:
            Jeremias Maerki
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development