-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Improve Spring Session auto-configuration tests #11063
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
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-projects/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-projects/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
SessionRepositoryFilter
bean in Servlet-based app, orWebSessionManager
bean in reactive app.I've added that change in this PR. This caused all of
ReactiveSessionAutoConfigurationMongoTests
to fail, as expected, until spring-projects/spring-session-data-mongodb#19 is fixed. But the change also causesSessionAutoConfigurationJdbcTests#defaultConfigWithUniqueStoreImplementation
andSessionAutoConfigurationHazelcastTests#defaultConfigWithUniqueStoreImplementation
- I haven't figured out why yet. Here are the details: