parent
9dd3fb70e2
commit
736a209e78
|
@ -23,25 +23,25 @@ import org.springframework.session.SessionRepository;
|
|||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Exception thrown when multiple {@link SessionRepository} implementations are
|
||||
* available with no way to know which implementation should be used.
|
||||
* Exception thrown when multiple {@link SessionRepository} implementations are available
|
||||
* with no way to know which implementation should be used.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class NonUniqueSessionRepositoryException extends RuntimeException {
|
||||
|
||||
private final List<Class<? extends SessionRepository>> availableCandidates;
|
||||
private final List<Class<? extends SessionRepository<?>>> availableCandidates;
|
||||
|
||||
public NonUniqueSessionRepositoryException(
|
||||
List<Class<? extends SessionRepository>> availableCandidates) {
|
||||
List<Class<? extends SessionRepository<?>>> availableCandidates) {
|
||||
super("Multiple session repository candidates are available, set the "
|
||||
+ "'spring.session.store-type' property accordingly");
|
||||
this.availableCandidates = (!ObjectUtils.isEmpty(availableCandidates)
|
||||
? availableCandidates : Collections.emptyList());
|
||||
}
|
||||
|
||||
public List<Class<? extends SessionRepository>> getAvailableCandidates() {
|
||||
public List<Class<? extends SessionRepository<?>>> getAvailableCandidates() {
|
||||
return this.availableCandidates;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ class NonUniqueSessionRepositoryFailureAnalyzer
|
|||
StringBuilder message = new StringBuilder();
|
||||
message.append(String.format("Multiple Spring Session store implementations are "
|
||||
+ "available on the classpath:%n"));
|
||||
for (Class<? extends SessionRepository> candidate : cause.getAvailableCandidates()) {
|
||||
for (Class<? extends SessionRepository<?>> candidate : cause
|
||||
.getAvailableCandidates()) {
|
||||
message.append(String.format(" - %s%n", candidate.getName()));
|
||||
}
|
||||
StringBuilder action = new StringBuilder();
|
||||
|
|
|
@ -106,7 +106,7 @@ public class SessionAutoConfiguration {
|
|||
|
||||
@PostConstruct
|
||||
public void checkAvailableImplementations() {
|
||||
List<Class<? extends SessionRepository>> candidates = new ArrayList<>();
|
||||
List<Class<? extends SessionRepository<?>>> candidates = new ArrayList<>();
|
||||
addCandidate(candidates,
|
||||
"org.springframework.session.hazelcast.HazelcastSessionRepository");
|
||||
addCandidate(candidates,
|
||||
|
@ -119,10 +119,12 @@ public class SessionAutoConfiguration {
|
|||
}
|
||||
}
|
||||
|
||||
private void addCandidate(
|
||||
List<Class<? extends SessionRepository>> candidates, String fqn) {
|
||||
@SuppressWarnings("unchecked")
|
||||
private void addCandidate(List<Class<? extends SessionRepository<?>>> candidates,
|
||||
String fqn) {
|
||||
try {
|
||||
Class<? extends SessionRepository> candidate = (Class<? extends SessionRepository>) this.classLoader.loadClass(fqn);
|
||||
Class<? extends SessionRepository<?>> candidate = (Class<? extends SessionRepository<?>>) this.classLoader
|
||||
.loadClass(fqn);
|
||||
if (candidate != null) {
|
||||
candidates.add(candidate);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,9 @@ public class NonUniqueSessionRepositoryFailureAnalyzerTests {
|
|||
assertThat(analysis.getAction()).contains("spring.session.store-type");
|
||||
}
|
||||
|
||||
private Exception createFailure(Class<? extends SessionRepository>... candidates) {
|
||||
@SafeVarargs
|
||||
private final Exception createFailure(
|
||||
Class<? extends SessionRepository<?>>... candidates) {
|
||||
return new NonUniqueSessionRepositoryException(Arrays.asList(candidates));
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@
|
|||
<spring-security.version>5.0.0.M3</spring-security.version>
|
||||
<spring-security-jwt.version>1.0.8.RELEASE</spring-security-jwt.version>
|
||||
<spring-security-oauth.version>2.2.0.RELEASE</spring-security-oauth.version>
|
||||
<spring-session.version>2.0.0.M3</spring-session.version>
|
||||
<spring-session.version>2.0.0.M4</spring-session.version>
|
||||
<spring-social.version>2.0.0.M3</spring-social.version>
|
||||
<spring-social-facebook.version>3.0.0.M2</spring-social-facebook.version>
|
||||
<spring-social-linkedin.version>2.0.0.M2</spring-social-linkedin.version>
|
||||
|
|
Loading…
Reference in New Issue