Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbeaver/pro#3465 udbt reconnect improve #3029

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.PeriodicJob;

import java.time.Duration;

public class SessionStateJob extends PeriodicJob {
private static final Log log = Log.getLog(SessionStateJob.class);
private static final int PERIOD_MS = 30_000; // once per 30 seconds
private final WebSessionManager sessionManager;

public SessionStateJob(@NotNull DBPPlatform platform, WebSessionManager sessionManager) {
super("Session state sender", platform, PERIOD_MS);
super("Session state sender", platform, Duration.ofSeconds(30));
this.sessionManager = sessionManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.PeriodicJob;

import java.time.Duration;

/**
* WebSessionMonitorJob
*/
public class WebSessionMonitorJob extends PeriodicJob {
private static final Log log = Log.getLog(WebSessionMonitorJob.class);
private static final int MONITOR_INTERVAL = 10000; // once per 10 seconds
private final WebSessionManager sessionManager;

public WebSessionMonitorJob(@NotNull DBPPlatform platform, @NotNull WebSessionManager sessionManager) {
super("Web session monitor", platform, MONITOR_INTERVAL);
super("Web session monitor", platform, Duration.ofSeconds(10));
this.sessionManager = sessionManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import io.cloudbeaver.DBWebException;
import io.cloudbeaver.auth.SMTokenCredentialProvider;
import io.cloudbeaver.server.AppWebSessionManager;
import io.cloudbeaver.model.session.*;
import io.cloudbeaver.registry.WebHandlerRegistry;
import io.cloudbeaver.registry.WebSessionHandlerDescriptor;
import io.cloudbeaver.server.AppWebSessionManager;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.server.CBConstants;
import io.cloudbeaver.server.events.WSWebUtils;
Expand Down Expand Up @@ -315,6 +315,14 @@ public WebHeadlessSession getHeadlessSession(Request request, Session session, b
var existSession = sessionMap.get(sessionId);

if (existSession instanceof WebHeadlessSession) {
var creds = existSession.getUserContext().getActiveUserCredentials();
if (creds == null || !smAccessToken.equals(creds.getSmAccessToken())) {
existSession.getUserContext().refresh(
smAccessToken,
null,
authPermissions
);
}
return (WebHeadlessSession) existSession;
}
if (existSession != null) {
Expand Down