Improve Spring Session auto-configuration tests#11063
Improve Spring Session auto-configuration tests#11063vpavic wants to merge 1 commit intospring-projects:masterfrom
Conversation
|
Unfortunately the tests fail unless we also upgrade the dependencies and I got the following error trying to do that:
|
|
Yes, this one is blocked for the same reason as #11055 and requires the upgrade of Spring Session Data MongoDB - note that spring-attic/spring-session-data-mongodb#19 was merged in the meanwhile. If I upgrade the |
a504cf4 to
c0dfd1a
Compare
|
With
|
|
@vpavic are you still looking at those two test failures or do you need help figuring out what is happening? |
|
@snicoll I did take another look at this after rebasing the PR this morning but wasn't able to figure it out so I'd appreciate if you could take a look. While debugging I noticed that This happens only with those two mentioned tests that manipulate the class loader using |
|
The failure of It fails because
In short, I think this is a bug in Spring Framework. It should be possible to reproduce this above-described behaviour in a standalone test case. I'll open an SPR issue if I am able to do so. |
|
I've opened SRP-16217. |
* gh-11063: Polish "Improve Spring Session auto-configuration tests" Improve Spring Session auto-configuration tests
|
Thanks for the PR, @vpavic. Having figured out the Framework problem described above, I realised it was only a problem here as |
|
Interesting problem indeed. Thanks for providing the detailed insight @wilkinsona. One thing that is still not clear to me is how come that Redis and its equivalent test, And would it be a good idea to apply the change analogous to 8a3502b to diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/MongoReactiveSessionConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/MongoReactiveSessionConfiguration.java
index d5cdeb81c9..42965a2de1 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/MongoReactiveSessionConfiguration.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/MongoReactiveSessionConfiguration.java
@@ -27,6 +27,7 @@ import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.core.ReactiveMongoOperations;
import org.springframework.session.ReactiveSessionRepository;
+import org.springframework.session.data.mongo.ReactiveMongoOperationsSessionRepository;
import org.springframework.session.data.mongo.config.annotation.web.reactive.ReactiveMongoWebSessionConfiguration;
/**
@@ -35,7 +36,8 @@ import org.springframework.session.data.mongo.config.annotation.web.reactive.Rea
* @author Andy Wilkinson
*/
@Configuration
-@ConditionalOnClass(ReactiveMongoWebSessionConfiguration.class)
+@ConditionalOnClass({ ReactiveMongoOperations.class,
+ ReactiveMongoOperationsSessionRepository.class })
@ConditionalOnMissingBean(ReactiveSessionRepository.class)
@ConditionalOnBean(ReactiveMongoOperations.class)
@Conditional(ReactiveSessionCondition.class) |
Align `MongoReactiveSessionConfiguration` `@ConditionalOnClass` with `MongoSessionConfiguration` See gh-11063
While putting together a sample Spring Session WebFlux app (see #11055), I've ran into spring-attic/spring-session-data-mongodb#19 - this should have arguably been picked up in Spring Session auto-configuration tests.
IMO it would be reasonable to improve session repository validation to include a check for
SessionRepositoryFilterbean in Servlet-based app, orWebSessionManagerbean in reactive app.I've added that change in this PR. This caused all of
ReactiveSessionAutoConfigurationMongoTeststo fail, as expected, until spring-attic/spring-session-data-mongodb#19 is fixed. But the change also causesSessionAutoConfigurationJdbcTests#defaultConfigWithUniqueStoreImplementationandSessionAutoConfigurationHazelcastTests#defaultConfigWithUniqueStoreImplementation- I haven't figured out why yet. Here are the details: