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

Reuse UuidSessionIdGenerationStrategy as default implementation #2385

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,6 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

/**
* <p>
Expand All @@ -44,6 +43,7 @@
*
* @author Rob Winch
* @author Vedran Pavic
* @author Yanming Zhou
* @since 1.0
*/
public final class MapSession implements Session, Serializable {
Expand Down Expand Up @@ -81,7 +81,7 @@ public final class MapSession implements Session, Serializable {
* Creates a new instance with a secure randomly generated identifier.
*/
public MapSession() {
this(generateId());
this(UuidSessionIdGenerationStrategy.getInstance());
}

/**
Expand Down Expand Up @@ -242,10 +242,6 @@ public int hashCode() {
return this.id.hashCode();
}

private static String generateId() {
return UUID.randomUUID().toString();
}

/**
* Sets the {@link SessionIdGenerationStrategy} to use when generating a new session
* id.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.function.Supplier;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -136,6 +135,7 @@
*
* @author Vedran Pavic
* @author Craig Andrews
* @author Yanming Zhou
* @since 2.2.0
*/
public class JdbcIndexedSessionRepository implements
Expand Down Expand Up @@ -467,7 +467,7 @@ public void setCleanupCron(String cleanupCron) {
public JdbcSession createSession() {
MapSession delegate = new MapSession(this.sessionIdGenerationStrategy);
delegate.setMaxInactiveInterval(this.defaultMaxInactiveInterval);
JdbcSession session = new JdbcSession(delegate, UUID.randomUUID().toString(), true);
JdbcSession session = new JdbcSession(delegate, delegate.getId(), true);
session.flushIfRequired();
return session;
}
Expand Down
Loading