[Fix] Fixing startup race condition on timeout of old sessions
This commit is contained in:
parent
cbee61577f
commit
e6697eb9c2
|
@ -137,7 +137,7 @@ public class DefaultStrolchPrivilegeHandler extends StrolchComponent implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void isCertificateValid(Certificate certificate) throws PrivilegeException {
|
public void isCertificateValid(Certificate certificate) throws PrivilegeException {
|
||||||
assertContainerStarted();
|
assertStarted();
|
||||||
this.privilegeHandler.isCertificateValid(certificate);
|
this.privilegeHandler.isCertificateValid(certificate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ public class DefaultStrolchPrivilegeHandler extends StrolchComponent implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sessionTimeout(Certificate certificate) {
|
public boolean sessionTimeout(Certificate certificate) {
|
||||||
assertContainerStarted();
|
assertStarted();
|
||||||
boolean invalidateSession = this.privilegeHandler.invalidateSession(certificate);
|
boolean invalidateSession = this.privilegeHandler.invalidateSession(certificate);
|
||||||
StrolchRealm realm = getContainer().getRealm(certificate);
|
StrolchRealm realm = getContainer().getRealm(certificate);
|
||||||
try (StrolchTransaction tx = realm.openTx(certificate, StrolchPrivilegeConstants.SESSION_TIME_OUT)) {
|
try (StrolchTransaction tx = realm.openTx(certificate, StrolchPrivilegeConstants.SESSION_TIME_OUT)) {
|
||||||
|
|
|
@ -98,8 +98,9 @@ public class DefaultStrolchSessionHandler extends StrolchComponent implements St
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sessionTimeoutTimer = new Timer("SessionTimeoutTimer", true); //$NON-NLS-1$
|
this.sessionTimeoutTimer = new Timer("SessionTimeoutTimer", true); //$NON-NLS-1$
|
||||||
|
long delay = TimeUnit.MINUTES.toMillis(5);
|
||||||
long checkInterval = TimeUnit.MINUTES.toMillis(1);
|
long checkInterval = TimeUnit.MINUTES.toMillis(1);
|
||||||
this.sessionTimeoutTimer.schedule(new SessionTimeoutTask(), checkInterval, checkInterval);
|
this.sessionTimeoutTimer.schedule(new SessionTimeoutTask(), delay, checkInterval);
|
||||||
|
|
||||||
super.start();
|
super.start();
|
||||||
}
|
}
|
||||||
|
@ -194,6 +195,7 @@ public class DefaultStrolchSessionHandler extends StrolchComponent implements St
|
||||||
synchronized (this.certificateMap) {
|
synchronized (this.certificateMap) {
|
||||||
removedCert = this.certificateMap.remove(certificate.getAuthToken());
|
removedCert = this.certificateMap.remove(certificate.getAuthToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removedCert == null)
|
if (removedCert == null)
|
||||||
logger.error(MessageFormat.format("No session was registered with token {0}", certificate.getAuthToken())); //$NON-NLS-1$
|
logger.error(MessageFormat.format("No session was registered with token {0}", certificate.getAuthToken())); //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue