From 96207a078e8a08de2be51383fe2ecfbe5d85aaee Mon Sep 17 00:00:00 2001 From: Chris Allan Date: Tue, 12 Mar 2024 13:26:05 +0000 Subject: [PATCH 1/2] Session bean actions should happen at `SYSTEM` priority --- .../java/ome/services/sessions/SessionBean.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/ome/services/sessions/SessionBean.java b/src/main/java/ome/services/sessions/SessionBean.java index 0d1b5b96c..68f20df79 100644 --- a/src/main/java/ome/services/sessions/SessionBean.java +++ b/src/main/java/ome/services/sessions/SessionBean.java @@ -29,6 +29,7 @@ import ome.security.basic.LightAdminPrivileges; import ome.services.sessions.SessionManager.CreationRequest; import ome.services.util.Executor; +import ome.services.util.Executor.Priority; import ome.system.Principal; import org.slf4j.Logger; @@ -94,7 +95,7 @@ public Session createUserSession(final long timeToLiveMs, cd.size() > 0 ? cd.getContext().get("omero.agent") : null; try { final Principal principal = principal(defaultGroup, user); - Future future = ex.submit(new Callable(){ + Future future = ex.submit(Priority.SYSTEM, new Callable(){ public Session call() throws Exception { final CreationRequest req = new CreationRequest(); req.principal = principal; @@ -153,7 +154,7 @@ public Session createSessionWithTimeouts(@NotNull final Principal principal, final String agent = cd.size() > 0 ? cd.getContext().get("omero.agent") : null; try { - Future future = ex.submit(new Callable(){ + Future future = ex.submit(Priority.SYSTEM, new Callable(){ public Session call() throws Exception { SessionManager.CreationRequest req = new SessionManager.CreationRequest(); req.principal = principal; @@ -213,7 +214,7 @@ public int getReferenceCount(@NotNull String sessionUuid) { @RolesAllowed( { "user", "guest" }) public Session updateSession(@NotNull final Session session) { - Future future = ex.submit(new Callable(){ + Future future = ex.submit(Priority.SYSTEM, new Callable(){ public Session call() throws Exception { return mgr.update(session); }}); @@ -222,7 +223,7 @@ public Session call() throws Exception { @RolesAllowed( { "user", "guest" }) public int closeSession(@NotNull final Session session) { - Future future = ex.submit(new Callable(){ + Future future = ex.submit(Priority.SYSTEM, new Callable(){ public Integer call() throws Exception { return mgr.close(session.getUuid()); }}); @@ -232,7 +233,7 @@ public Integer call() throws Exception { @RolesAllowed("user") public java.util.List getMyOpenSessions() { final String uuid = currentContext().getCurrentSessionUuid(); - Future> future = ex.submit(new Callable>(){ + Future> future = ex.submit(Priority.SYSTEM, new Callable>(){ public List call() throws Exception { return mgr.findSameUser(uuid); }}); @@ -242,7 +243,7 @@ public List call() throws Exception { @RolesAllowed("user") public java.util.List getMyOpenAgentSessions(final String agent) { final String uuid = currentContext().getCurrentSessionUuid(); - Future> future = ex.submit(new Callable>(){ + Future> future = ex.submit(Priority.SYSTEM, new Callable>(){ public List call() throws Exception { return mgr.findSameUser(uuid, agent); }}); @@ -252,7 +253,7 @@ public List call() throws Exception { @RolesAllowed("user") public java.util.List getMyOpenClientSessions() { final String uuid = currentContext().getCurrentSessionUuid(); - Future> future = ex.submit(new Callable>(){ + Future> future = ex.submit(Priority.SYSTEM, new Callable>(){ public List call() throws Exception { return mgr.findSameUser(uuid, "OMERO.insight", "OMERO.web", "OMERO.importer"); From 6c1426b72fb6ff05453aeccbc1fbf3848d13e638 Mon Sep 17 00:00:00 2001 From: Chris Allan Date: Wed, 13 Mar 2024 09:05:07 +0000 Subject: [PATCH 2/2] Executor.submit() invoked on 2 argument overload --- .../java/ome/server/utests/sessions/SessionBeanUnitTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/ome/server/utests/sessions/SessionBeanUnitTest.java b/src/test/java/ome/server/utests/sessions/SessionBeanUnitTest.java index a39055ebb..9a5a66fdb 100644 --- a/src/test/java/ome/server/utests/sessions/SessionBeanUnitTest.java +++ b/src/test/java/ome/server/utests/sessions/SessionBeanUnitTest.java @@ -111,7 +111,7 @@ private void expectsExecutorSubmit() { exMock.expects(once()).method("submit").will(new Stub(){ public Object invoke(Invocation arg0) throws Throwable { - Callable callable = (Callable) arg0.parameterValues.get(0); + Callable callable = (Callable) arg0.parameterValues.get(1); final Object rv = callable.call(); return new Future() { @@ -154,4 +154,4 @@ public StringBuffer describeTo(StringBuffer arg0) { return arg0; }}); } -} \ No newline at end of file +}