Skip to content

Commit

Permalink
CB-4836 convert max idle time to seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-skoblikov committed Mar 28, 2024
1 parent eaa26df commit 4dfc7b2
Showing 1 changed file with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package io.cloudbeaver.server.jetty;

import io.cloudbeaver.model.app.WebServerConfigurationController;
import io.cloudbeaver.registry.WebServiceRegistry;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.server.CBServerConfig;
Expand Down Expand Up @@ -201,31 +200,19 @@ private void initSessionManager(
}
}

SessionHandler sessionHandler = new SessionHandler()/* {
public HttpCookie access(HttpSession session, boolean secure) {
HttpCookie cookie = getSessionCookie(session, _context == null ? "/" : (_context.getContextPath()), secure);
return cookie;
}
@Override
public int getRefreshCookieAge() {
// Refresh cookie always (we need it for FA requests)
return 1;
}
}*/;
var maxIdleSeconds = application.getMaxSessionIdleTime();
SessionHandler sessionHandler = new SessionHandler();

Check warning on line 203 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/jetty/CBJettyServer.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/jetty/CBJettyServer.java#L203

Distance between variable sessionHandler declaration and its first usage is 4, but allowed 3. Consider making that variable final if you still need to store its value in advance (before method calls that might have side effects on the original value).
var maxIdleTime = application.getMaxSessionIdleTime();
int intMaxIdleSeconds;
if (maxIdleSeconds > Integer.MAX_VALUE) {
if (maxIdleTime > Integer.MAX_VALUE) {
log.warn("Max session idle time value is greater than Integer.MAX_VALUE. Integer.MAX_VALUE will be used instead");
intMaxIdleSeconds = Integer.MAX_VALUE;
} else {
intMaxIdleSeconds = (int) maxIdleSeconds;
maxIdleTime = Integer.MAX_VALUE;
}
intMaxIdleSeconds = (int) (maxIdleTime / 1000);
log.debug("Max http session idle time: " + intMaxIdleSeconds + "s");
sessionHandler.setMaxInactiveInterval(intMaxIdleSeconds);

DefaultSessionCache sessionCache = new DefaultSessionCache(sessionHandler);
FileSessionDataStore sessionStore = new FileSessionDataStore();

sessionStore.setStoreDir(sessionCacheFolder.toFile());
sessionCache.setSessionDataStore(sessionStore);
sessionHandler.setSessionCache(sessionCache);
Expand Down

0 comments on commit 4dfc7b2

Please sign in to comment.