This is an automated email from the ASF dual-hosted git repository.
anovikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-extensions.git
The following commit(s) were added to refs/heads/master by this push:
new 8f50f512 IGNITE-22077 Add spring 6 support to spring session extension
(#262)
8f50f512 is described below
commit 8f50f512ac48fe8be9660b4c78e99a55a7a41ae2
Author: Nusrat Shakarov <[email protected]>
AuthorDate: Wed May 22 07:19:09 2024 +0200
IGNITE-22077 Add spring 6 support to spring session extension (#262)
---
.../bin/include/jvmdefaults.sh | 2 +-
modules/spring-session-ext/pom.xml | 28 ++++---
.../sessions/IgniteHttpSessionConfiguration.java | 14 +++-
.../sessions/IgniteIndexedSessionRepository.java | 29 ++++++-
.../IgniteHttpSessionConfigurationTest.java | 3 +-
parent-internal/pom.xml | 97 ++++++++++++++++++++++
pom.xml | 10 ++-
7 files changed, 165 insertions(+), 18 deletions(-)
diff --git a/modules/performance-statistics-ext/bin/include/jvmdefaults.sh
b/modules/performance-statistics-ext/bin/include/jvmdefaults.sh
index d30fe005..94c0cadf 100644
--- a/modules/performance-statistics-ext/bin/include/jvmdefaults.sh
+++ b/modules/performance-statistics-ext/bin/include/jvmdefaults.sh
@@ -144,7 +144,7 @@ getJavaSpecificOpts() {
--add-opens=java.base/java.time=ALL-UNNAMED \
--add-opens=java.base/java.text=ALL-UNNAMED \
--add-opens=java.management/sun.management=ALL-UNNAMED \
- --add-opens java.desktop/java.awt.font=ALL-UNNAMED \
+ --add-opens=java.desktop/java.awt.font=ALL-UNNAMED \
${current_value}"
fi
diff --git a/modules/spring-session-ext/pom.xml
b/modules/spring-session-ext/pom.xml
index 72f725ce..4be5e346 100644
--- a/modules/spring-session-ext/pom.xml
+++ b/modules/spring-session-ext/pom.xml
@@ -30,15 +30,17 @@
</parent>
<artifactId>ignite-spring-session-ext</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<url>https://ignite.apache.org</url>
<properties>
- <spring.session.version>2.5.0</spring.session.version>
- <spring.security.version>5.5.0</spring.security.version>
- <javax.annotation.version>1.3.2</javax.annotation.version>
+ <maven.compiler.release>17</maven.compiler.release>
+
+ <spring.session.version>3.2.2</spring.session.version>
+ <spring.security.version>6.2.4</spring.security.version>
+ <jakarta.annotation.version>3.0.0</jakarta.annotation.version>
<assertj.version>3.20.0</assertj.version>
- <junit.jupiter.version>5.7.2</junit.jupiter.version>
+ <junit.jupiter.version>5.10.2</junit.jupiter.version>
<javax.servlet.version>3.0.1</javax.servlet.version>
</properties>
@@ -48,7 +50,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
- <version>${spring53.version}</version>
+ <version>${spring61.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -99,9 +101,9 @@
</dependency>
<dependency>
- <groupId>javax.annotation</groupId>
- <artifactId>javax.annotation-api</artifactId>
- <version>${javax.annotation.version}</version>
+ <groupId>jakarta.annotation</groupId>
+ <artifactId>jakarta.annotation-api</artifactId>
+ <version>${jakarta.annotation.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
@@ -151,8 +153,14 @@
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
- </dependencies>
+ <!--
https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api -->
+ <dependency>
+ <groupId>jakarta.servlet</groupId>
+ <artifactId>jakarta.servlet-api</artifactId>
+ <version>6.0.0</version>
+ </dependency>
+ </dependencies>
<build>
<plugins>
diff --git
a/modules/spring-session-ext/src/main/java/org/apache/ignite/spring/sessions/IgniteHttpSessionConfiguration.java
b/modules/spring-session-ext/src/main/java/org/apache/ignite/spring/sessions/IgniteHttpSessionConfiguration.java
index 61f1fa37..a06006bb 100644
---
a/modules/spring-session-ext/src/main/java/org/apache/ignite/spring/sessions/IgniteHttpSessionConfiguration.java
+++
b/modules/spring-session-ext/src/main/java/org/apache/ignite/spring/sessions/IgniteHttpSessionConfiguration.java
@@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import jakarta.annotation.PostConstruct;
import org.apache.ignite.Ignite;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.client.IgniteClient;
@@ -79,6 +80,9 @@ public class IgniteHttpSessionConfiguration extends
SpringHttpSessionConfigurati
/** */
private List<SessionRepositoryCustomizer<IgniteIndexedSessionRepository>>
sesRepoCustomizers;
+ /** */
+ private Object connObj;
+
/**
* @return Session repository.
*/
@@ -134,7 +138,15 @@ public class IgniteHttpSessionConfiguration extends
SpringHttpSessionConfigurati
if (connObj == null)
connObj = cli.getIfAvailable();
- this.sessions = createSessionProxy(connObj);
+ this.connObj = connObj;
+ }
+
+ /**
+ * Init sessions.
+ */
+ @PostConstruct
+ public void initSessions() {
+ this.sessions = createSessionProxy(this.connObj);
}
/**
diff --git
a/modules/spring-session-ext/src/main/java/org/apache/ignite/spring/sessions/IgniteIndexedSessionRepository.java
b/modules/spring-session-ext/src/main/java/org/apache/ignite/spring/sessions/IgniteIndexedSessionRepository.java
index 25a3e315..c7857b1e 100644
---
a/modules/spring-session-ext/src/main/java/org/apache/ignite/spring/sessions/IgniteIndexedSessionRepository.java
+++
b/modules/spring-session-ext/src/main/java/org/apache/ignite/spring/sessions/IgniteIndexedSessionRepository.java
@@ -22,7 +22,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-import javax.annotation.PreDestroy;
+import jakarta.annotation.PreDestroy;
import javax.cache.configuration.CacheEntryListenerConfiguration;
import javax.cache.configuration.Factory;
import javax.cache.event.CacheEntryCreatedListener;
@@ -47,6 +47,8 @@ import org.springframework.session.MapSession;
import org.springframework.session.PrincipalNameIndexResolver;
import org.springframework.session.SaveMode;
import org.springframework.session.Session;
+import org.springframework.session.SessionIdGenerator;
+import org.springframework.session.UuidSessionIdGenerator;
import org.springframework.session.events.AbstractSessionEvent;
import org.springframework.session.events.SessionCreatedEvent;
import org.springframework.session.events.SessionDeletedEvent;
@@ -121,6 +123,9 @@ public class IgniteIndexedSessionRepository
/** The index resolver. */
private IndexResolver<Session> idxResolver = new
DelegatingIndexResolver<>(new PrincipalNameIndexResolver<>());
+ /** Session id generator. */
+ private SessionIdGenerator sessionIdGenerator =
UuidSessionIdGenerator.getInstance();
+
/** Sessions cache proxy. */
private final SessionProxy sessions;
@@ -216,6 +221,15 @@ public class IgniteIndexedSessionRepository
this.saveMode = saveMode;
}
+ /**
+ * Set session id generator.
+ * @param sesIdGenerator Session id generator.
+ */
+ public void setSessionIdGenerator(SessionIdGenerator sesIdGenerator) {
+ Assert.notNull(sesIdGenerator, "sessionIdGenerator cannot be null");
+ this.sessionIdGenerator = sesIdGenerator;
+ }
+
/** {@inheritDoc} */
@Override public IgniteSession createSession() {
MapSession cached = new MapSession();
@@ -223,11 +237,15 @@ public class IgniteIndexedSessionRepository
if (this.dfltMaxInactiveInterval != null)
cached.setMaxInactiveInterval(Duration.ofSeconds(this.dfltMaxInactiveInterval));
+ cached.setSessionIdGenerator(this.sessionIdGenerator);
+
return new IgniteSession(cached, idxResolver, true, saveMode,
this::flushImmediateIfNecessary);
}
/** {@inheritDoc} */
@Override public void save(IgniteSession ses) {
+ ses.getDelegate().setSessionIdGenerator(this.sessionIdGenerator);
+
if (ses.isNew())
ttlSessions(ses.getMaxInactiveInterval()).put(ses.getId(), ses);
else {
@@ -263,7 +281,10 @@ public class IgniteIndexedSessionRepository
return null;
}
- return new IgniteSession(saved.getDelegate(), idxResolver, false,
saveMode, this::flushImmediateIfNecessary);
+ MapSession mapSession = saved.getDelegate();
+ mapSession.setSessionIdGenerator(this.sessionIdGenerator);
+
+ return new IgniteSession(mapSession, idxResolver, false, saveMode,
this::flushImmediateIfNecessary);
}
/** {@inheritDoc} */
@@ -389,7 +410,7 @@ public class IgniteIndexedSessionRepository
if (oldSes == null)
break;
- updatedSes = new IgniteSession(oldSes.getDelegate(), idxResolver,
false, saveMode, this::flushImmediateIfNecessary);
+ updatedSes = new IgniteSession(new
MapSession(oldSes.getDelegate()), idxResolver, false, saveMode,
this::flushImmediateIfNecessary);
copyChanges(updatedSes, ses);
if (attempt > MAX_UPDATE_ATTEMPT) {
@@ -399,6 +420,6 @@ public class IgniteIndexedSessionRepository
ttlSessions(ses.getMaxInactiveInterval()).replace(ses.getId(),
updatedSes);
break;
}
- } while
(ttlSessions(ses.getMaxInactiveInterval()).replace(ses.getId(), oldSes,
updatedSes));
+ } while
(!ttlSessions(ses.getMaxInactiveInterval()).replace(ses.getId(), oldSes,
updatedSes));
}
}
diff --git
a/modules/spring-session-ext/src/test/java/org/apache/ignite/spring/sessions/IgniteHttpSessionConfigurationTest.java
b/modules/spring-session-ext/src/test/java/org/apache/ignite/spring/sessions/IgniteHttpSessionConfigurationTest.java
index a6b2f185..fd7ea137 100644
---
a/modules/spring-session-ext/src/test/java/org/apache/ignite/spring/sessions/IgniteHttpSessionConfigurationTest.java
+++
b/modules/spring-session-ext/src/test/java/org/apache/ignite/spring/sessions/IgniteHttpSessionConfigurationTest.java
@@ -217,7 +217,7 @@ public class IgniteHttpSessionConfigurationTest {
void multipleIgniteConfiguration() {
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() ->
registerAndRefresh(MultipleIgniteConfiguration.class))
- .withMessageContaining("expected single matching bean but found
2");
+ .withStackTraceContaining("expected single matching bean but found
2");
}
/** */
@@ -410,6 +410,7 @@ public class IgniteHttpSessionConfigurationTest {
/** */
@Bean
+ @Primary
Ignite ignite() {
return mockedIgnite(igniteSessions);
}
diff --git a/parent-internal/pom.xml b/parent-internal/pom.xml
index f00f5c7a..bd2d1e17 100644
--- a/parent-internal/pom.xml
+++ b/parent-internal/pom.xml
@@ -38,6 +38,7 @@
<spring-boot.version>2.2.13.RELEASE</spring-boot.version>
<spring.data.version>2.2.13.RELEASE</spring.data.version>
<spring53.version>5.3.19</spring53.version>
+ <spring61.version>6.1.6</spring61.version>
<!--
NOTE: The dependency versions below must be changed in the release
branch up to
@@ -191,5 +192,101 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>java-9+</id>
+ <activation>
+ <jdk>[9,)</jdk>
+ </activation>
+ <properties>
+ <maven.compiler.release>8</maven.compiler.release>
+ </properties>
+ </profile>
+ <profile>
+ <id>java-15+</id>
+ <activation>
+ <jdk>[15,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <!-- Do not bring ignite logic -->
+ <inherited>false</inherited>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkCount>1</forkCount>
+ <argLine>
+
--add-opens=java.base/jdk.internal.access=ALL-UNNAMED
+
--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED
+
--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED
+
--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED
+ --add-opens=java.base/sun.nio.ch=ALL-UNNAMED
+
--add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED
+
--add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED
+
--add-opens=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED
+
--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
+ --add-opens=java.base/java.io=ALL-UNNAMED
+ --add-opens=java.base/java.net=ALL-UNNAMED
+ --add-opens=java.base/java.nio=ALL-UNNAMED
+
--add-opens=java.base/java.security.cert=ALL-UNNAMED
+ --add-opens=java.base/java.util=ALL-UNNAMED
+
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
+
--add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED
+
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
+ --add-opens=java.base/java.lang=ALL-UNNAMED
+
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
+ --add-opens=java.base/java.time=ALL-UNNAMED
+
--add-opens=java.base/sun.security.ssl=ALL-UNNAMED
+
--add-opens=java.base/sun.security.x509=ALL-UNNAMED
+ --add-opens=java.base/sun.net.util=ALL-UNNAMED
+ --add-opens=java.sql/java.sql=ALL-UNNAMED
+
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
+ --add-opens=java.base/java.text=ALL-UNNAMED
+
--add-opens=java.desktop/java.awt.font=ALL-UNNAMED
+ </argLine>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>io.gatling</groupId>
+ <artifactId>gatling-maven-plugin</artifactId>
+ <configuration>
+ <jvmArgs>
+
<jvmArg>--add-opens=java.base/jdk.internal.access=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/sun.nio.ch=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.io=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.net=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.nio=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.security.cert=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.util=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.util.concurrent=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.lang=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.lang.invoke=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.time=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/sun.security.ssl=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/sun.security.x509=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/sun.net.util=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.sql/java.sql=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.lang.reflect=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.base/java.text=ALL-UNNAMED</jvmArg>
+
<jvmArg>--add-opens=java.desktop/java.awt.font=ALL-UNNAMED</jvmArg>
+ </jvmArgs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
diff --git a/pom.xml b/pom.xml
index cebf1479..33710bdb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,7 +47,6 @@
<module>modules/performance-statistics-ext</module>
<module>modules/spring-tx-ext</module>
<module>modules/spring-cache-ext</module>
- <module>modules/spring-session-ext</module>
<module>modules/cdc-ext</module>
<module>modules/aws-ext</module>
<module>modules/azure-ext</module>
@@ -74,6 +73,15 @@
<module>../ignite</module>
</modules>
</profile>
+ <profile>
+ <id>java-17+</id>
+ <activation>
+ <jdk>[17,)</jdk>
+ </activation>
+ <modules>
+ <module>modules/spring-session-ext</module>
+ </modules>
+ </profile>
</profiles>
<build>