[
https://issues.apache.org/jira/browse/SMX4-1382?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jean-Baptiste Onofré updated SMX4-1382:
---------------------------------------
Fix Version/s: (was: specs-2.3.0)
specs-2.4.0
> URL.equals() causes massive delay for shutdown of a Locator-enabled bundle
> --------------------------------------------------------------------------
>
> Key: SMX4-1382
> URL: https://issues.apache.org/jira/browse/SMX4-1382
> Project: ServiceMix 4
> Issue Type: Bug
> Environment: Win7 64bit, Oracle JVM 6.0_29 64bit, Apache Felix 3.0.9
> Reporter: Jeremias Maerki
> Labels: Performance
> Fix For: specs-2.4.0
>
>
> 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)
--
This message was sent by Atlassian JIRA
(v6.1#6144)