[ 
https://issues.apache.org/jira/browse/WICKET-6157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15267308#comment-15267308
 ] 

Ilia Naryzhny commented on WICKET-6157:
---------------------------------------

Original exception in my case (which is absent in case of real app):

[ERROR] (2016-05-02 12:15:41,408) ModuledDataInstallator: Exception during 
destroying module 'devutils'
org.apache.wicket.WicketRuntimeException: There is no application attached to 
current thread Thread-6
        at org.apache.wicket.Application.get(Application.java:236)
        at 
org.apache.wicket.core.request.mapper.AbstractComponentMapper.getContext(AbstractComponentMapper.java:47)
        at 
org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper.processBookmarkable(AbstractBookmarkableMapper.java:239)
        at 
org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper.mapRequest(AbstractBookmarkableMapper.java:358)
        at 
org.apache.wicket.protocol.http.WebApplication.unmountFromCompound(WebApplication.java:468)
        at 
org.apache.wicket.protocol.http.WebApplication.unmount(WebApplication.java:449)
        at 
org.orienteer.core.OrienteerWebApplication.mountOrUnmountPages(OrienteerWebApplication.java:293)
        at 
org.orienteer.core.OrienteerWebApplication.unmountPages(OrienteerWebApplication.java:263)
        at 
org.orienteer.core.OrienteerWebApplication.unmountPages(OrienteerWebApplication.java:259)
        at org.orienteer.devutils.Module.onDestroy(Module.java:41)
        at 
org.orienteer.core.module.AbstractOrienteerModule.onDestroy(AbstractOrienteerModule.java:105)
        at 
org.orienteer.core.module.ModuledDataInstallator.onBeforeDestroyed(ModuledDataInstallator.java:135)
        at 
org.apache.wicket.ApplicationListenerCollection$2.notify(ApplicationListenerCollection.java:52)
        at 
org.apache.wicket.ApplicationListenerCollection$2.notify(ApplicationListenerCollection.java:48)
        at 
org.apache.wicket.util.listener.ListenerCollection$1.notify(ListenerCollection.java:120)
        at 
org.apache.wicket.util.listener.ListenerCollection.reversedNotify(ListenerCollection.java:144)
        at 
org.apache.wicket.util.listener.ListenerCollection.reversedNotifyIgnoringExceptions(ListenerCollection.java:113)
        at 
org.apache.wicket.ApplicationListenerCollection.onBeforeDestroyed(ApplicationListenerCollection.java:47)
        at org.apache.wicket.Application.internalDestroy(Application.java:776)
        at 
org.apache.wicket.protocol.http.WebApplication.internalDestroy(WebApplication.java:704)
        at 
org.apache.wicket.util.tester.BaseWicketTester.destroy(BaseWicketTester.java:620)
        at 
org.orienteer.junit.StaticInjectorProvider$1.run(StaticInjectorProvider.java:35)


> WicketTester and application servers are destroying app differently
> -------------------------------------------------------------------
>
>                 Key: WICKET-6157
>                 URL: https://issues.apache.org/jira/browse/WICKET-6157
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 7.2.0
>            Reporter: Ilia Naryzhny
>              Labels: wicket-tester
>
> It's easy to recieve NPE because of absence of App in context in test during 
> destroying app and it's OK on real app. The reason is the following:
> Wicket Test has just this code:
> ```
>       public void destroy()
>       {
>               application.internalDestroy();
>               ThreadContext.detach();
>       }
> ```
> But real filter has this one:
> ```
> @Override
>       public void destroy()
>       {
>               if (application != null)
>               {
>                       try
>                       {
>                               ThreadContext.setApplication(application);
>                               application.internalDestroy();
>                       }
>                       finally
>                       {
>                               ThreadContext.detach();
>                               application = null;
>                       }
>               }
>               if (applicationFactory != null)
>               {
>                       try
>                       {
>                               applicationFactory.destroy(this);
>                       }
>                       finally
>                       {
>                               applicationFactory = null;
>                       }
>               }
>       }
> ```
> So, as you can see filter explicitly setting app, so NPE would not happen, 
> but wicket tester do not. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to