UI.detach(..) called twice with @Push

Hello,

I am using @Push and what I see is the detach() method is called twice.

It seems UI.setSession(…) calls setPushConnection(null), which eventually calls detach() second time. detach(); <-- first time // Close the push connection when UI is detached. Otherwise the // push connection and possibly VaadinSession will live on. setPushConnection(null); <-- second time

In com.vaadin.server.communication.PushHandler:
@Override public void onResume(AtmosphereResourceEvent event) { // Log event on trace level super.onResume(event); disconnect(event); <-- this is going to call VaadinService.requestEnd(..) again }

Any comments? Is it a configuration/coding mistake on my part?
Thanks.

P.S. Stack traces:

First time:

"http-bio-8443-exec-6@57" daemon prio=5 tid=0x6a nid=NA runnable
  java.lang.Thread.State: RUNNABLE
      at com.javtech.appiahq.config.editor.MainServlet.detach(MainServlet.java:2491)
      at com.vaadin.ui.UI.setSession(UI.java:420)
      at com.vaadin.server.VaadinSession.removeUI(VaadinSession.java:832)
      at com.vaadin.server.VaadinService$2.run(VaadinService.java:1144)
      at com.vaadin.ui.UI.accessSynchronously(UI.java:1231)
      at com.vaadin.server.VaadinService.removeClosedUIs(VaadinService.java:1138)
      at com.vaadin.server.VaadinService.cleanupSession(VaadinService.java:1103)
      at com.vaadin.server.VaadinService$4.run(VaadinService.java:1308)
      at com.vaadin.server.VaadinSession.accessSynchronously(VaadinSession.java:1251)
      at com.vaadin.server.VaadinService.requestEnd(VaadinService.java:1305)
      at com.vaadin.server.communication.PushHandler.callWithUi(PushHandler.java:315)
      at com.vaadin.server.communication.PushHandler.onRequest(PushHandler.java:347)
      at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:259)
      at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:166)
      at org.atmosphere.container.TomcatWebSocketUtil.doService(TomcatWebSocketUtil.java:137)
      at org.atmosphere.container.Tomcat7AsyncSupportWithWebSocket.service(Tomcat7AsyncSupportWithWebSocket.java:59)
      at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1448)
      at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:219)
      at org.atmosphere.websocket.DefaultWebSocketProcessor$2.run(DefaultWebSocketProcessor.java:183)
      at org.atmosphere.util.VoidExecutorService.execute(VoidExecutorService.java:101)
      at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:178)
      at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:167)
      at org.atmosphere.container.TomcatWebSocketHandler.onTextMessage(TomcatWebSocketHandler.java:92)
      at org.apache.catalina.websocket.MessageInbound.onTextData(MessageInbound.java:77)
      at org.apache.catalina.websocket.StreamInbound.doOnTextData(StreamInbound.java:190)
      at org.apache.catalina.websocket.StreamInbound.onData(StreamInbound.java:138)
      at org.apache.coyote.http11.upgrade.UpgradeProcessor.upgradeDispatch(UpgradeProcessor.java:88)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:599)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      - locked <0x365> (a org.apache.tomcat.util.net.SocketWrapper)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:724)   

Second time:

[font=arial]
[size=1]

at com.javtech.appiahq.config.editor.MainServlet.detach(MainServlet.java:2491)
      at com.vaadin.ui.UI.setSession(UI.java:420)
      at com.vaadin.server.VaadinSession.removeUI(VaadinSession.java:832)
      at com.vaadin.server.VaadinService$2.run(VaadinService.java:1144)
      at com.vaadin.ui.UI.accessSynchronously(UI.java:1231)
      at com.vaadin.server.VaadinService.removeClosedUIs(VaadinService.java:1138)
      at com.vaadin.server.VaadinService.cleanupSession(VaadinService.java:1103)
      at com.vaadin.server.VaadinService$4.run(VaadinService.java:1308)
      at com.vaadin.server.VaadinSession.accessSynchronously(VaadinSession.java:1251)
      at com.vaadin.server.VaadinService.requestEnd(VaadinService.java:1305)
      at com.vaadin.server.communication.PushHandler.callWithUi(PushHandler.java:315)
      at com.vaadin.server.communication.PushHandler.disconnect(PushHandler.java:429)
      at com.vaadin.server.communication.PushHandler.onResume(PushHandler.java:421)
      at org.atmosphere.cpr.AtmosphereResourceImpl.onResume(AtmosphereResourceImpl.java:818)
      at org.atmosphere.cpr.AtmosphereResourceImpl.notifyListeners(AtmosphereResourceImpl.java:771)
      at org.atmosphere.cpr.AtmosphereResourceImpl.notifyListeners(AtmosphereResourceImpl.java:749)
      at org.atmosphere.cpr.AtmosphereResourceImpl.resume(AtmosphereResourceImpl.java:297)
      at com.vaadin.server.communication.AtmospherePushConnection.disconnect(AtmospherePushConnection.java:223)
      at com.vaadin.ui.UI.setPushConnection(UI.java:1431)
      at com.vaadin.ui.UI.setSession(UI.java:423)
      at com.vaadin.server.VaadinSession.removeUI(VaadinSession.java:832)
      at com.vaadin.server.VaadinService$2.run(VaadinService.java:1144)
      at com.vaadin.ui.UI.accessSynchronously(UI.java:1231)
      at com.vaadin.server.VaadinService.removeClosedUIs(VaadinService.java:1138)
      at com.vaadin.server.VaadinService.cleanupSession(VaadinService.java:1103)
      at com.vaadin.server.VaadinService$4.run(VaadinService.java:1308)
      at com.vaadin.server.VaadinSession.accessSynchronously(VaadinSession.java:1251)
      at com.vaadin.server.VaadinService.requestEnd(VaadinService.java:1305)
      at com.vaadin.server.communication.PushHandler.callWithUi(PushHandler.java:315)
      at com.vaadin.server.communication.PushHandler.onRequest(PushHandler.java:347)
      at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:259)
      at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:166)
      at org.atmosphere.container.TomcatWebSocketUtil.doService(TomcatWebSocketUtil.java:137)
      at org.atmosphere.container.Tomcat7AsyncSupportWithWebSocket.service(Tomcat7AsyncSupportWithWebSocket.java:59)
      at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1448)
      at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:219)
      at org.atmosphere.websocket.DefaultWebSocketProcessor$2.run(DefaultWebSocketProcessor.java:183)
      at org.atmosphere.util.VoidExecutorService.execute(VoidExecutorService.java:101)
      at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:178)
      at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:167)
      at org.atmosphere.container.TomcatWebSocketHandler.onTextMessage(TomcatWebSocketHandler.java:92)
      at org.apache.catalina.websocket.MessageInbound.onTextData(MessageInbound.java:77)
      at org.apache.catalina.websocket.StreamInbound.doOnTextData(StreamInbound.java:190)
      at org.apache.catalina.websocket.StreamInbound.onData(StreamInbound.java:138)
      at org.apache.coyote.http11.upgrade.UpgradeProcessor.upgradeDispatch(UpgradeProcessor.java:88)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:599)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      - locked <0x1a9> (a org.apache.tomcat.util.net.SocketWrapper)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:724)

[/size]
[/font]

Thanks! I actually found this same issue just a few days ago, but didn’t yet create a ticket for it. Yes, it’s definitely a bug in Vaadin; specifically it’s a regression in 7.1.6 caused by commit
3a4351f9
. I’ll open a ticket ASAP.

Thank you for your response and for opening the ticket. Sorry, I forgot to mention the version (7.1.8).

Created
ticket #12985
.