This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit 96e7a3a91e14e7f55e9d7da2209d50e933a1f02e Author: Alex Heneveld <[email protected]> AuthorDate: Mon Sep 13 10:48:02 2021 +0100 prevent race/error in session lookup --- .../rest/util/MultiSessionAttributeAdapter.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/MultiSessionAttributeAdapter.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/MultiSessionAttributeAdapter.java index f950786..0b1878e 100644 --- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/MultiSessionAttributeAdapter.java +++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/MultiSessionAttributeAdapter.java @@ -152,7 +152,22 @@ public class MultiSessionAttributeAdapter { if (localSession==null) { preferredSession = FACTORY.findValidPreferredSession(null, r); if(preferredSession!=null) { - localSession = r.getSession(); + // need to create a local session so the ID/session is registered with this ui module + if (r instanceof Request) { + // but synch on the session handler to avoid race conditions in the underlying code +// 2021-09-13T08:12:33,186Z - WARN 254 o.e.j.s.session [p1568796312-1154] +// java.lang.IllegalStateException: Session node0171nuqxrc6qsf1tbrmxztok6xc4 already in cache +// at org.eclipse.jetty.server.session.AbstractSessionCache.add(AbstractSessionCache.java:467) ~[!/:9.4.39.v20210325] +// at org.eclipse.jetty.server.session.SessionHandler.newHttpSession(SessionHandler.java:770) ~[!/:9.4.39.v20210325] +// at org.eclipse.jetty.server.Request.getSession(Request.java:1628) ~[!/:9.4.39.v20210325] +// at org.eclipse.jetty.server.Request.getSession(Request.java:1602) ~[!/:9.4.39.v20210325] +// at org.apache.brooklyn.rest.util.MultiSessionAttributeAdapter.of(MultiSessionAttributeAdapter.java:155) ~[!/:1.1.0-SNAPSHOT] + synchronized (((Request)r).getSessionHandler()) { + localSession = r.getSession(); + } + } else { + localSession = r.getSession(); + } } } else { preferredSession = FACTORY.findPreferredSession(r);
