Skip to content
Snippets Groups Projects
Commit 2a4e77c2 authored by gpawel's avatar gpawel
Browse files

bugfix: make synchronization more smart

SVN: 26720
parent 67954bc0
No related branches found
No related tags found
No related merge requests found
...@@ -101,19 +101,22 @@ public class OpenBISAuthenticationInterceptor implements MethodInterceptor ...@@ -101,19 +101,22 @@ public class OpenBISAuthenticationInterceptor implements MethodInterceptor
} }
/**
* authenticate when the session has expired.
*/
@Override @Override
public synchronized Object invoke(MethodInvocation invocation) throws Throwable public Object invoke(MethodInvocation invocation) throws Throwable
{ {
checkSessionToken(); String sessionToken = getSessionToken();
try try
{ {
return invocation.proceed(); return invocation.proceed();
} catch (InvalidSessionException ise) } catch (InvalidSessionException ise)
{ {
authenticate(); synchronized (this)
{
if (sessionToken == sessionHolder.getSessionToken())
{
authenticate();
}
}
return invocation.proceed(); return invocation.proceed();
} }
} }
...@@ -151,12 +154,21 @@ public class OpenBISAuthenticationInterceptor implements MethodInterceptor ...@@ -151,12 +154,21 @@ public class OpenBISAuthenticationInterceptor implements MethodInterceptor
service.registerDataStoreServer(sessionToken, dataStoreServerInfo); service.registerDataStoreServer(sessionToken, dataStoreServerInfo);
} }
private final void checkSessionToken() /**
* authenticates when the session has expired.
*/
private final String getSessionToken()
{ {
if (sessionHolder.getSessionToken() == null) if (sessionHolder.getSessionToken() == null)
{ {
authenticate(); synchronized (this)
{
if (sessionHolder.getSessionToken() == null)
authenticate();
}
} }
return sessionHolder.getSessionToken();
} }
public final void setPort(int port) public final void setPort(int port)
......
...@@ -30,7 +30,7 @@ public class OpenBISSessionHolder implements Serializable, ISessionTokenProvider ...@@ -30,7 +30,7 @@ public class OpenBISSessionHolder implements Serializable, ISessionTokenProvider
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String sessionToken; private volatile String sessionToken;
private String dataStoreCode; private String dataStoreCode;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment