在 Vaadin 请求中,如何在 Liferay 的 APPLICATION_SCOPE 中设置属性

How can I set an attribute in Liferay's APPLICATION_SCOPE whilst inside of a Vaadin request

一些背景;我是 运行 Vaadin 7 应用程序,作为 Liferay 6.2.GA6 运行 上使用 DeltaManager 的集群 Tomcat7 实例上的 portlet。

我正在尝试在我的 Vaadin 应用程序中设置其他 portlet 可以查看并做出适当反应的用户级会话属性。

下面的代码导致线程死锁。

'    
PortletSession session = ((WrappedPortletSession)UI.getCurrent().getSesion()).getPortletSession();
session.setAttribute("CURRENT_NOTIFICATION",notificationDTO,PortletSession.APPLICATION_SCOPE);

我生成的缩写线程转储...

"http-nio-8081-exec-80" - Thread t@1030
   java.lang.Thread.State: WAITING
    at sun.misc.Unsafe.park(Native Method)
    - waiting to lock <7c3f1e38> (a java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync) owned by "http-nio-8081-exec-82" t@1036
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
    at java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:945)
    at org.apache.catalina.ha.session.DeltaSession.lock(DeltaSession.java:199)
    at org.apache.catalina.ha.session.DeltaSession.setAttribute(DeltaSession.java:726)
    at org.apache.catalina.ha.session.DeltaSession.setAttribute(DeltaSession.java:711)
    at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:154)
    at com.liferay.portlet.PortletSessionImpl.setAttribute(PortletSessionImpl.java:188)
    at mypackage.com.view.NotificationEntryView.enter(NotificationEntryView.java:181)


    "http-nio-8081-exec-82" - Thread t@1036
   java.lang.Thread.State: WAITING
    at sun.misc.Unsafe.park(Native Method)
    - waiting to lock <fa6510c> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) owned by "http-nio-8081-exec-80" t@1030
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
    at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:214)
    at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:290)
    at com.vaadin.server.VaadinSession.writeObject(VaadinSession.java:1432)
    at sun.reflect.GeneratedMethodAccessor1827.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
    at org.apache.catalina.ha.session.DeltaRequest$AttributeInfo.writeExternal(DeltaRequest.java:407)
    at org.apache.catalina.ha.session.DeltaRequest.writeExternal(DeltaRequest.java:300)
    at org.apache.catalina.ha.session.DeltaRequest.serialize(DeltaRequest.java:314)
    at org.apache.catalina.ha.session.DeltaManager.serializeDeltaRequest(DeltaManager.java:610)
    at org.apache.catalina.ha.session.DeltaManager.requestCompleted(DeltaManager.java:996)
    - locked <5603aa01> (a org.apache.catalina.ha.session.DeltaRequest)

似乎对 PorletSession 的 setAttribute 调用触发了 DeltaSession 以尝试锁定 Vaadin 已经(某种程度上)持有哪些死锁的会话。

Vaadin 建议使用 VaadinSession 或 UI.access()。这没有帮助。

我接下来的想法是手动解锁VaadinSession,设置Attribute,然后重新锁定VaadinSession,这似乎是一个冒险的举动。

谁能推荐一个解决方案?

在设置用户会话属性之前解锁 VaadinSession 似乎解决了死锁问题,重新锁定 VaadinSession 似乎也有效。

所以问题暂时解决了。