Ensure compatibility with Java 9 and 10

Closes gh-1196
This commit is contained in:
Vedran Pavic
2018-09-14 08:32:45 +02:00
parent 9f6e791e5d
commit 3e1a22102d
9 changed files with 80 additions and 28 deletions

18
Jenkinsfile vendored
View File

@@ -27,6 +27,24 @@ try {
} }
} }
} }
},
jdk10: {
stage('JDK 10') {
timeout(time: 30, unit: 'MINUTES') {
node('ubuntu1804') {
checkout scm
try {
withEnv(["JAVA_HOME=${tool 'jdk10'}"]) {
sh './gradlew clean test --no-daemon --refresh-dependencies'
}
}
catch (e) {
currentBuild.result = 'FAILED: jdk10'
throw e
}
}
}
}
} }
if (currentBuild.result == 'SUCCESS') { if (currentBuild.result == 'SUCCESS') {

View File

@@ -1,20 +1,39 @@
buildscript { buildscript {
ext {
releaseBuild = version.endsWith('RELEASE')
snapshotBuild = version.endsWith('SNAPSHOT')
milestoneBuild = !(releaseBuild || snapshotBuild)
springBootVersion = '2.1.0.M3'
}
repositories {
gradlePluginPortal()
maven { url 'https://repo.spring.io/plugins-release/' }
maven { url 'https://repo.spring.io/plugins-snapshot/' }
}
dependencies { dependencies {
classpath 'io.spring.gradle:spring-build-conventions:0.0.18.RELEASE' classpath 'io.spring.gradle:spring-build-conventions:0.0.19.BUILD-SNAPSHOT'
classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion" classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
} }
repositories {
maven { url 'https://repo.spring.io/plugins-release' }
}
} }
apply plugin: 'io.spring.convention.root' apply plugin: 'io.spring.convention.root'
group = 'org.springframework.session' group = 'org.springframework.session'
description = 'Spring Session' description = 'Spring Session'
gradle.taskGraph.whenReady { graph ->
ext.releaseBuild = version.endsWith('RELEASE') def jacocoEnabled = graph.allTasks.any { it instanceof JacocoReport }
ext.snapshotBuild = version.endsWith('SNAPSHOT') subprojects {
ext.milestoneBuild = !(releaseBuild || snapshotBuild) plugins.withType(JavaPlugin) {
sourceCompatibility = 1.8
}
plugins.withType(JacocoPlugin) {
tasks.withType(Test) {
jacoco.enabled = jacocoEnabled
}
}
}
}

View File

@@ -1,2 +1 @@
springBootVersion=2.1.0.M3
version=2.1.0.BUILD-SNAPSHOT version=2.1.0.BUILD-SNAPSHOT

View File

@@ -1,13 +1,16 @@
rootProject.name = 'spring-session-build' rootProject.name = 'spring-session'
FileTree buildFiles = fileTree(rootDir) { FileTree buildFiles = fileTree(rootDir) {
include '**/*.gradle' include '**/*.gradle'
exclude '**/gradle', 'settings.gradle', 'buildSrc', '/build.gradle', '.*' exclude 'build', '**/gradle', 'settings.gradle', 'buildSrc', '/build.gradle', '.*', 'out'
exclude '**/grails3' exclude '**/grails3'
gradle.startParameter.projectProperties.get('excludeProjects')?.split(',')?.each { excludeProject ->
exclude excludeProject
}
} }
String rootDirPath = rootDir.absolutePath + File.separator String rootDirPath = rootDir.absolutePath + File.separator
buildFiles.each { File buildFile -> buildFiles.each { buildFile ->
if (buildFile.name == 'build.gradle') { if (buildFile.name == 'build.gradle') {
String buildFilePath = buildFile.parentFile.absolutePath String buildFilePath = buildFile.parentFile.absolutePath
String projectPath = buildFilePath.replace(rootDirPath, '').replace(File.separator, ':') String projectPath = buildFilePath.replace(rootDirPath, '').replace(File.separator, ':')

View File

@@ -17,6 +17,7 @@
package org.springframework.session.security; package org.springframework.session.security;
import java.time.Instant; import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -74,7 +75,9 @@ public class SpringSessionBackedSessionRegistryTest {
.getSessionInformation(SESSION_ID); .getSessionInformation(SESSION_ID);
assertThat(sessionInfo.getSessionId()).isEqualTo(SESSION_ID); assertThat(sessionInfo.getSessionId()).isEqualTo(SESSION_ID);
assertThat(sessionInfo.getLastRequest().toInstant()).isEqualTo(NOW); assertThat(
sessionInfo.getLastRequest().toInstant().truncatedTo(ChronoUnit.MILLIS))
.isEqualTo(NOW.truncatedTo(ChronoUnit.MILLIS));
assertThat(sessionInfo.getPrincipal()).isEqualTo(USER_NAME); assertThat(sessionInfo.getPrincipal()).isEqualTo(USER_NAME);
assertThat(sessionInfo.isExpired()).isFalse(); assertThat(sessionInfo.isExpired()).isFalse();
} }
@@ -90,7 +93,9 @@ public class SpringSessionBackedSessionRegistryTest {
.getSessionInformation(SESSION_ID); .getSessionInformation(SESSION_ID);
assertThat(sessionInfo.getSessionId()).isEqualTo(SESSION_ID); assertThat(sessionInfo.getSessionId()).isEqualTo(SESSION_ID);
assertThat(sessionInfo.getLastRequest().toInstant()).isEqualTo(NOW); assertThat(
sessionInfo.getLastRequest().toInstant().truncatedTo(ChronoUnit.MILLIS))
.isEqualTo(NOW.truncatedTo(ChronoUnit.MILLIS));
assertThat(sessionInfo.getPrincipal()).isEqualTo(USER_NAME); assertThat(sessionInfo.getPrincipal()).isEqualTo(USER_NAME);
assertThat(sessionInfo.isExpired()).isTrue(); assertThat(sessionInfo.isExpired()).isTrue();
} }

View File

@@ -346,12 +346,16 @@ public class ReactiveRedisOperationsSessionRepositoryTests {
.isEqualTo(expected.getAttribute(attribute1)); .isEqualTo(expected.getAttribute(attribute1));
assertThat(session.<String>getAttribute(attribute2)) assertThat(session.<String>getAttribute(attribute2))
.isEqualTo(expected.getAttribute(attribute2)); .isEqualTo(expected.getAttribute(attribute2));
assertThat(session.getCreationTime()).isEqualTo(expected.getCreationTime()); assertThat(session.getCreationTime().truncatedTo(ChronoUnit.MILLIS))
assertThat(session.getMaxInactiveInterval()) .isEqualTo(expected.getCreationTime()
.truncatedTo(ChronoUnit.MILLIS));
assertThat(session.getMaxInactiveInterval())
.isEqualTo(expected.getMaxInactiveInterval()); .isEqualTo(expected.getMaxInactiveInterval());
assertThat(session.getLastAccessedTime()) assertThat(
.isEqualTo(expected.getLastAccessedTime()); session.getLastAccessedTime().truncatedTo(ChronoUnit.MILLIS))
}).verifyComplete(); .isEqualTo(expected.getLastAccessedTime()
.truncatedTo(ChronoUnit.MILLIS));
}).verifyComplete();
} }
@Test @Test

View File

@@ -432,12 +432,12 @@ public class RedisOperationsSessionRepositoryTests {
.isEqualTo(expected.getAttribute(attribute1)); .isEqualTo(expected.getAttribute(attribute1));
assertThat(session.<String>getAttribute(attribute2)) assertThat(session.<String>getAttribute(attribute2))
.isEqualTo(expected.getAttribute(attribute2)); .isEqualTo(expected.getAttribute(attribute2));
assertThat(session.getCreationTime()).isEqualTo(expected.getCreationTime()); assertThat(session.getCreationTime().truncatedTo(ChronoUnit.MILLIS))
.isEqualTo(expected.getCreationTime().truncatedTo(ChronoUnit.MILLIS));
assertThat(session.getMaxInactiveInterval()) assertThat(session.getMaxInactiveInterval())
.isEqualTo(expected.getMaxInactiveInterval()); .isEqualTo(expected.getMaxInactiveInterval());
assertThat(session.getLastAccessedTime()) assertThat(session.getLastAccessedTime().truncatedTo(ChronoUnit.MILLIS))
.isEqualTo(expected.getLastAccessedTime()); .isEqualTo(expected.getLastAccessedTime().truncatedTo(ChronoUnit.MILLIS));
} }
@Test @Test
@@ -498,9 +498,11 @@ public class RedisOperationsSessionRepositoryTests {
RedisSession session = sessionIdToSessions.get(sessionId); RedisSession session = sessionIdToSessions.get(sessionId);
assertThat(session).isNotNull(); assertThat(session).isNotNull();
assertThat(session.getId()).isEqualTo(sessionId); assertThat(session.getId()).isEqualTo(sessionId);
assertThat(session.getLastAccessedTime()).isEqualTo(lastAccessed); assertThat(session.getLastAccessedTime().truncatedTo(ChronoUnit.MILLIS))
.isEqualTo(lastAccessed.truncatedTo(ChronoUnit.MILLIS));
assertThat(session.getMaxInactiveInterval()).isEqualTo(maxInactive); assertThat(session.getMaxInactiveInterval()).isEqualTo(maxInactive);
assertThat(session.getCreationTime()).isEqualTo(createdTime); assertThat(session.getCreationTime().truncatedTo(ChronoUnit.MILLIS))
.isEqualTo(createdTime.truncatedTo(ChronoUnit.MILLIS));
} }
@Test @Test

View File

@@ -3,6 +3,7 @@ apply plugin: 'io.spring.convention.spring-module'
dependencies { dependencies {
compile project(':spring-session-core') compile project(':spring-session-core')
compile "com.hazelcast:hazelcast" compile "com.hazelcast:hazelcast"
compile "javax.annotation:javax.annotation-api"
compile "org.springframework:spring-context" compile "org.springframework:spring-context"
testCompile "javax.servlet:javax.servlet-api" testCompile "javax.servlet:javax.servlet-api"

View File

@@ -172,7 +172,8 @@ public abstract class AbstractJdbcOperationsSessionRepositoryITests {
assertThat(session.isChanged()).isFalse(); assertThat(session.isChanged()).isFalse();
assertThat(session.getDelta()).isEmpty(); assertThat(session.getDelta()).isEmpty();
assertThat(session.isExpired()).isFalse(); assertThat(session.isExpired()).isFalse();
assertThat(session.getLastAccessedTime()).isEqualTo(lastAccessedTime); assertThat(session.getLastAccessedTime().truncatedTo(ChronoUnit.MILLIS))
.isEqualTo(lastAccessedTime.truncatedTo(ChronoUnit.MILLIS));
} }
@Test @Test