File tree 1 file changed +9
-3
lines changed
spring-session-data-mongodb/src/main/java/org/springframework/session/data/mongo
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 22
22
import org .apache .commons .logging .LogFactory ;
23
23
import org .bson .Document ;
24
24
import reactor .core .publisher .Mono ;
25
+ import reactor .core .scheduler .Schedulers ;
25
26
26
27
import org .springframework .beans .factory .InitializingBean ;
27
28
import org .springframework .context .ApplicationEvent ;
@@ -97,12 +98,17 @@ public ReactiveMongoSessionRepository(ReactiveMongoOperations mongoOperations) {
97
98
*/
98
99
@ Override
99
100
public Mono <MongoSession > createSession () {
100
- return Mono .defer (() -> Mono .just (this .sessionIdGenerationStrategy .generate ()))
101
- .map ((sessionId ) -> new MongoSession (sessionId , this .defaultMaxInactiveInterval .toSeconds ()))
101
+ // @formatter:off
102
+ return Mono .fromSupplier (() -> this .sessionIdGenerationStrategy .generate ())
103
+ .map (MongoSession ::new )
104
+ .doOnNext ((mongoSession ) -> mongoSession .setMaxInactiveInterval (this .defaultMaxInactiveInterval ))
102
105
.doOnNext (
103
106
(mongoSession ) -> mongoSession .setSessionIdGenerationStrategy (this .sessionIdGenerationStrategy ))
104
107
.doOnNext ((mongoSession ) -> publishEvent (new SessionCreatedEvent (this , mongoSession )))
105
- .switchIfEmpty (Mono .just (new MongoSession (this .sessionIdGenerationStrategy )));
108
+ .switchIfEmpty (Mono .just (new MongoSession (this .sessionIdGenerationStrategy )))
109
+ .subscribeOn (Schedulers .boundedElastic ())
110
+ .publishOn (Schedulers .parallel ());
111
+ // @formatter:on
106
112
}
107
113
108
114
@ Override
You can’t perform that action at this time.
0 commit comments