Details
Description
During my integration testing for the new scripts I ran into this issue.
It seems that some viewstate "pointers" are not cleared up properly in my test case, and reference after a while state entries which have dropped out of the state history.
The problem is not related to my scripts, because the same test works for jsf 2.3 flawlessly with the same scripts and a 2.3 shim. So the Javascript code executed is the same.
Reproducible:
https://github.com/werpu/myfaces-js-integrationtests/tree/faces_40_viestate_bug
then run the project via mvn clean clean install exec:java -f pom.xml
then point your browser to: http://localhost:8080/IntegrationJSTest/loop/test8-navcase1.jsf?autoTest=true
or follow the link to the loop navigation test in the index.html
The test case performs an implicit Ajax navigation by sending a faces.request execute on a command link, which triggers the navigation.
Note, only the command link is sent as execute not the entire form, but the entire form is refreshed.
Let it run, after roughly a minute you should get following error:
java.lang.NullPointerException
viewId=/loop/test8-navcase1.xhtml
location=/Users/werpu2/development/workspace/myfaces-js-integrationtests/src/main/webapp/loop/test8-navcase1.xhtml
phaseId=RENDER_RESPONSE(6)
Caused by:
java.lang.NullPointerException
at org.apache.myfaces.cdi.util.AbstractContextualStorageHolder.destroyAll(AbstractContextualStorageHolder.java:201)
Stack Trace:
{{java.lang.NullPointerException
at org.apache.myfaces.cdi.util.AbstractContextualStorageHolder.destroyAll(AbstractContextualStorageHolder.java:201)
at org.apache.myfaces.cdi.util.AbstractContextualStorageHolder.destroyAll(AbstractContextualStorageHolder.java:242)
at org.apache.myfaces.cdi.view.ViewScopeContextualStorageHolder$Proxy$_$$_WeldClientProxy.destroyAll(Unknown Source)
at org.apache.myfaces.cdi.view.ViewScopeContext.destroyAll(ViewScopeContext.java:202)
at org.apache.myfaces.application.viewstate.SerializedViewCollection.lambda$put$1(SerializedViewCollection.java:71)
at org.apache.myfaces.application.viewstate.SerializedViewCollection.put(SerializedViewCollection.java:228)
at org.apache.myfaces.application.viewstate.SerializedViewCollection.put(SerializedViewCollection.java:70)
at org.apache.myfaces.application.viewstate.StateCacheServerSide.saveSerializedViewInSession(StateCacheServerSide.java:196)
at org.apache.myfaces.application.viewstate.StateCacheServerSide.saveSerializedView(StateCacheServerSide.java:465)
at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.saveState(HtmlResponseStateManager.java:107)
at org.apache.myfaces.view.facelets.PartialStateManagementStrategy.saveView(PartialStateManagementStrategy.java:794)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1854)
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:316)
at jakarta.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:74)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:122)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
at jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:225)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:400)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1739)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)}}