felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Moore (JIRA)" <j...@apache.org>
Subject [jira] Commented: (FELIX-827) URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
Date Fri, 21 Nov 2008 00:44:46 GMT

    [ https://issues.apache.org/jira/browse/FELIX-827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12649555#action_12649555

Tim Moore commented on FELIX-827:

The short answer is yes, if I set that property I don't get the error.

It's not a great workaround for us, however, because it means that the webapp doesn't get
fully unloaded and so leaks memory every time it's redeployed. The use case we have is automated
nightly deployment to a test server, so after a few days it will run out of permgen space
and I'd rather not have to go in and restart Tomcat manually every so often. We also can't
disable URLHandlers, since something somewhere in the app is using "bundle:" URLs.

I made a patch that seems to correct the problem at least for our case. It keeps track of
the root URLHandlers instance separately from m_streamHandlerFactory variable. Then it always
calls unregisterFrameworkListsForContextSearch on the root URLHandlers, either directly if
it's in the same classloader, or through reflection otherwise.

I'll attach the patch to this issue. I haven't run into any problems with it yet, but I'm
not sure it's 100% correct --- in fact, the more I think about it, I'm pretty sure it doesn't
handle all possible cases correctly (e.g., if multiple webapps using Felix are deployed, then
the first is removed).

I think that maybe a better implementation would have a chain of URLHandlers with the instance
stored in URL.factory on one end, and on the other end an instance that delegates to whatever
factory was installed before any Felix instances started. When a new Felix starts, it would
swap itself with the delegate at the end of the chain, if any, and when an instance stops,
it will replace itself with its delegate, either by setting its parent's delegate to its own,
or if it's currently the root, replacing URL.factory with its delegate. What do you think?
If you think this makes sense I can try to code it up and attach a new patch.

> URLHandlers does not restore the previous URLStreamHandlerFactory after stopping Felix
> --------------------------------------------------------------------------------------
>                 Key: FELIX-827
>                 URL: https://issues.apache.org/jira/browse/FELIX-827
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-1.2.1
, felix-1.4.0
>            Reporter: Tim Moore
>            Assignee: Karl Pauls
>             Fix For: felix-1.4.1
>         Attachments: test-felix-handler-1.0-SNAPSHOT.jar, test-felix-handler.zip
> I'm running Felix embedded inside a webapp, running in Tomcat.
> Tomcat installs its own URLStreamHandlerFactory. Felix swaps it out correctly when I
start it, and seems to delegate properly. When the webapp is unloaded, however, and it stops
Felix, it does not restore the previous implementation, but rather leaves the existing URLHandlers
instance installed. Then, if I try to redeploy the webapp without restarting the JVM, I get
errors, because Tomcat automatically sets the URLHandlers class's static members to null when
it unloads the webapp. (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41939)
> I've tested this on 1.2.1 and 1.4.0, and both versions have this problem.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message