Skip to content

Commit

Permalink
dbeaver-vscode# jetty 12 conflict fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-skoblikov committed Sep 17, 2024
1 parent a3bcca6 commit 6c8acb8
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.cloudbeaver.model.WebConnectionInfo;
import io.cloudbeaver.model.WebServerMessage;
import io.cloudbeaver.model.app.WebApplication;
import io.cloudbeaver.model.app.WebAuthApplication;
import io.cloudbeaver.model.user.WebUser;
import io.cloudbeaver.service.DBWSessionHandler;
import io.cloudbeaver.service.sql.WebSQLConstants;
Expand Down Expand Up @@ -126,17 +127,19 @@ public class WebSession extends BaseWebSession
public WebSession(
@NotNull WebHttpRequestInfo requestInfo,
@NotNull WebAuthApplication application,
@NotNull HttpServletRequest request,
@NotNull WebApplication application,
@NotNull Map<String, DBWSessionHandler> sessionHandlers
) throws DBException {
this(
request.getSession().getId(),
CommonUtils.toString(request.getSession().getAttribute(ATTR_LOCALE), null),
application,
sessionHandlers
);
updateSessionParameters(request);
super(requestInfo.getId(), application);
this.lastAccessTime = this.createTime;
setLocale(CommonUtils.toString(requestInfo.getLocale(), this.locale));
this.sessionHandlers = sessionHandlers;
//force authorization of anonymous session to avoid access error,
//because before authorization could be called by any request,
//but now 'updateInfo' is called only in special requests,
//and the order of requests is not guaranteed.
//look at CB-4747
refreshSessionAuth();
updateSessionParameters(requestInfo);
}

protected WebSession(
Expand All @@ -145,10 +148,8 @@ protected WebSession(
@NotNull WebApplication application,
@NotNull Map<String, DBWSessionHandler> sessionHandlers
) throws DBException {
super(requestInfo.getId(), application);
super(id, application);
this.lastAccessTime = this.createTime;
setLocale(CommonUtils.toString(requestInfo.getLocale(), this.locale));
this.sessionHandlers = sessionHandlers;
setLocale(locale);
//force authorization of anonymous session to avoid access error,
Expand All @@ -157,7 +158,6 @@ protected WebSession(
//and the order of requests is not guaranteed.
//look at CB-4747
refreshSessionAuth();
updateSessionParameters(requestInfo);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model.app;
package io.cloudbeaver.server;

import io.cloudbeaver.DBWebException;
import io.cloudbeaver.model.session.BaseWebSession;
import io.cloudbeaver.model.session.WebHeadlessSession;
import io.cloudbeaver.model.session.WebSession;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Session;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
Expand Down Expand Up @@ -54,7 +56,7 @@ WebSession getWebSession(

Collection<BaseWebSession> getAllActiveSessions();

Check warning on line 57 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L57

Missing a Javadoc comment.

WebSession getOrRestoreSession(HttpServletRequest httpRequest);
WebSession getOrRestoreSession(Request httpRequest);

Check warning on line 59 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L59

Missing a Javadoc comment.

WebHeadlessSession getHeadlessSession(Request request, Session session, boolean create) throws DBException;

Check warning on line 61 in server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java

View check run for this annotation

Jenkins-CI-integration / CheckStyle Java Report

server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/server/AppWebSessionManager.java#L61

Missing a Javadoc comment.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.cloudbeaver.WebServiceUtils;
import io.cloudbeaver.auth.NoAuthCredentialsProvider;
import io.cloudbeaver.model.app.BaseWebApplication;
import io.cloudbeaver.model.app.GQLApplicationAdapter;
import io.cloudbeaver.model.app.WebAuthApplication;
import io.cloudbeaver.model.app.WebAuthConfiguration;
import io.cloudbeaver.registry.WebDriverRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
package io.cloudbeaver.server;

import io.cloudbeaver.auth.NoAuthCredentialsProvider;
import io.cloudbeaver.model.app.AppWebSessionManager;
import io.cloudbeaver.model.app.GQLApplicationAdapter;
import io.cloudbeaver.server.jobs.SessionStateJob;
import io.cloudbeaver.server.jobs.WebDataSourceMonitorJob;
import io.cloudbeaver.server.jobs.WebSessionMonitorJob;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.model.app;
package io.cloudbeaver.server;

import io.cloudbeaver.model.app.WebApplication;
import io.cloudbeaver.registry.WebDriverRegistry;
import org.jkiss.code.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package io.cloudbeaver.server.jetty;

import io.cloudbeaver.model.app.GQLApplicationAdapter;
import io.cloudbeaver.server.GQLApplicationAdapter;
import io.cloudbeaver.registry.WebServiceRegistry;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.server.CBServerConfig;
Expand Down Expand Up @@ -137,7 +137,12 @@ public void runServer() {
);
servletContextHandler.insertHandler(webSocketHandler);

initSessionManager(this.application, server, servletContextHandler);
initSessionManager(
this.application.getMaxSessionIdleTime(),
this.application,
server,
servletContextHandler
);

server.setHandler(servletContextHandler);

Expand Down Expand Up @@ -192,8 +197,7 @@ public static void initSessionManager(
@NotNull ServletContextHandler servletContextHandler
) {
// Init sessions persistence
SessionHandler sessionHandler = new SessionHandler();
var maxIdleTime = application.getMaxSessionIdleTime();
CBSessionHandler sessionHandler = new CBSessionHandler(application);

Check warning on line 200 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#L200

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).
int intMaxIdleSeconds;
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package io.cloudbeaver.server.jetty;

import io.cloudbeaver.model.app.GQLApplicationAdapter;
import io.cloudbeaver.server.GQLApplicationAdapter;
import jakarta.servlet.SessionCookieConfig;
import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
import org.eclipse.jetty.ee10.servlet.SessionHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package io.cloudbeaver.server.jobs;

import io.cloudbeaver.model.app.AppWebSessionManager;
import io.cloudbeaver.server.AppWebSessionManager;
import io.cloudbeaver.model.session.BaseWebSession;
import io.cloudbeaver.model.session.WebSession;
import org.jkiss.code.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
*/
package io.cloudbeaver.server.websockets;

import io.cloudbeaver.model.app.AppWebSessionManager;
import io.cloudbeaver.server.AppWebSessionManager;
import io.cloudbeaver.model.session.BaseWebSession;
import io.cloudbeaver.model.session.WebHeadlessSession;
import io.cloudbeaver.model.session.WebHttpRequestInfo;
import io.cloudbeaver.server.CBPlatform;
import io.cloudbeaver.service.session.WebSessionManager;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.websocket.server.ServerUpgradeRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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;
Expand Down

0 comments on commit 6c8acb8

Please sign in to comment.