I was trying to have switch between multiple databases at runtime by GridFsTemplate seems to take the database name only once and using it by default in other threads
my spring boot version is 3.2.5 and my spring-data-mongodb-4.2.5
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-mongodb</artifactId> <version>4.2.5</version> </dependency>
this is happening after upgrading to springboot 3.2.5 and java 17
I tried in old version using java 11 and spring boot 2.6.3 and it is working properly, In new version the code is changed and it is taking from the bucketSupplier
the new version
private GridFSBucket getGridFs() { return (GridFSBucket)this.bucketSupplier.get(); }
and old version
`private GridFSBucket getGridFs() {
MongoDatabase db = dbFactory.getMongoDatabase();
return bucket == null ? GridFSBuckets.create(db) : GridFSBuckets.create(db, bucket);`
}
Divakar V is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.