Skip to content

Consistent property prefixes for Spring Session MongoDB and Spring Data MongoDB #9625

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

Closed
wants to merge 1 commit into from

Conversation

vpavic
Copy link
Contributor

@vpavic vpavic commented Jun 28, 2017

This resolves #9552.

Changes are mostly a revert of 33dd9d6 adopted with ones from #9554. There are however a few other changes:

  • new dependency management version spring-session-mongodb.version which is currently set to 2.0.0.BUILD-SNAPSHOT (next milestone should be 2.0.0.M2)
  • MongoDB related configuration properties are renamed to mongodb to be consistent with naming (module was previously named spring-session-data-mongo, now is spring-session-data-mongodb)
  • MongoDB related tests are moved to SessionAutoConfigurationMongoTests

Depending on release date of Spring Session MongoDB 2.0.0.M2 this could be targeted at Boot's 2.0.0.M3 (#9552 is currently targeted at 2.0.0.M4).

/cc @rwinch @gregturn

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 28, 2017
@gregturn
Copy link
Contributor

Looks great!

@philwebb
Copy link
Member

See also #9552 (comment) with some discussion about how we should deal with Spring Session now that it has been split up.

@philwebb philwebb added priority: normal type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 6, 2017
Integer timeout = sessionProperties.getTimeout();
if (timeout != null) {
setMaxInactiveIntervalInSeconds(timeout);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a suggestion, to be a bit more java 8 and fluent, you might use: Optional.ofNullable(sessionProperties.getTimeout()).ifPresent(this::setMaxInactiveIntervalInSeconds);

@wilkinsona
Copy link
Member

Sorry, @vpavic. I'd missed that we had this PR for #9552. What I've done is largely the same as what you'd proposed here. One notable difference is that I've kept the store type as Mongo rather than MongoDB. That was purely to avoid a change from what we had in 1.5. If the Spring Session team feel that we should go with the DB suffix that I'm not opposed to doing so.

@wilkinsona wilkinsona closed this Sep 21, 2017
@vpavic
Copy link
Contributor Author

vpavic commented Sep 21, 2017

I've rebased the changes from this PR on top of changes from c00a42f.

Basically the only difference is naming concerns from bullet no. 2 of the opening comment:

MongoDB related configuration properties are renamed to mongodb to be consistent with naming (module was previously named spring-session-mongo, now is spring-session-mongodb)

Those could still be worth getting in, both for reasons above and consistency with spring.data.mongodb.

@wilkinsona wilkinsona reopened this Sep 21, 2017
@wilkinsona wilkinsona changed the title Reinstate Spring Session MongoDB auto-config Use MongoDB rather than Mongo in class names and properties for Spring Session MongoDB Sep 21, 2017
@wilkinsona
Copy link
Member

Reopening to consider the Mongo -> MongoDb renaming

@wilkinsona
Copy link
Member

wilkinsona commented Sep 21, 2017

While the module is now named spring-session-mongodb its classes all just use Mongo (@EnableMongoHttpSession for example). Using Mongo rather than MongoDb is also consistent with Spring Data MongoDB's class names (MongoOperations for example) and Boot's existing Mongo-related classes (MongoAutoConfiguration and MongoProperties for example). For these reasons I think we should stick with Mongo rather than MongoDb.

@wilkinsona wilkinsona closed this Sep 21, 2017
@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed priority: normal type: enhancement A general enhancement labels Sep 21, 2017
@vpavic
Copy link
Contributor Author

vpavic commented Sep 21, 2017

OK, I agree that class names should stay as they are. But my primary concern was actually StoreType#MONGO vs StoreType#MONGODB and configuration properties namespace spring.session.mongo vs spring.session.mongodb. Spring Data MongoDB's namespace is spring.data.mongodb.

@wilkinsona
Copy link
Member

Hmm, you make a compelling point regarding the property prefix. Things are inconsistent at the moment and I don't like that.

@wilkinsona wilkinsona reopened this Sep 22, 2017
@wilkinsona wilkinsona added priority: normal type: enhancement A general enhancement and removed status: declined A suggestion or change that we don't feel we should currently apply labels Sep 22, 2017
@wilkinsona wilkinsona changed the title Use MongoDB rather than Mongo in class names and properties for Spring Session MongoDB Consistent property prefixes for Spring Session MongoDB and Spring Data MongoDB Sep 22, 2017
@wilkinsona wilkinsona added for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Sep 22, 2017
@wilkinsona
Copy link
Member

In summary, our configuration property prefix for Spring Data MongoDB is currently (in both 1.5.x and master) spring.data.mongodb whereas the prefix for Spring Session MongoDB is spring.session.mongo. We also have a MONGO value in the StoreType enum.

I think we should make this consistent. The proposal here is to align by changing the Spring Session-related names. Specifically, the prefix would become spring.session.mongodb and MONGO would become MONGODB in the StoreType enum. The is a breaking change from 1.5. Given the other Spring Session changes in 2.0, making a breaking change to our Spring Session support rather than our Spring Data MongoDB support feels to me like the right thing to do. Thoughts?

@vpavic
Copy link
Contributor Author

vpavic commented Sep 22, 2017

Thanks for reconsidering this. I've update the PR to remove the class renaming noise - it should now more clearly reflect the changes that are under consideration.

@@ -427,8 +427,8 @@ content into your application; rather pick only the properties that you need.
spring.session.jdbc.schema=classpath:org/springframework/session/jdbc/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema.
spring.session.jdbc.table-name=SPRING_SESSION # Name of database table used to store sessions.

# SPRING SESSION MONGO ({sc-spring-boot-autoconfigure}/session/MonogoSessionProperties.{sc-ext}[MongoSessionProperties])
spring.session.mongo.collection-name=sessions # Collection name used to store sessions.
# SPRING SESSION MONGODB ({sc-spring-boot-autoconfigure}/session/MongoDbSessionProperties.{sc-ext}[MongoDbSessionProperties])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should stay as MongoSessionProperties

@snicoll
Copy link
Member

snicoll commented Sep 25, 2017

Specifically, the prefix would become spring.session.mongodb and MONGO would become MONGODB in the StoreType enum

+1 to that. Sorry, we discussed this before and didn't catch that inconsistency either :(

@wilkinsona wilkinsona removed the for: team-attention An issue we'd like other members of the team to review label Sep 25, 2017
@wilkinsona wilkinsona added this to the 2.0.0.M5 milestone Sep 25, 2017
@wilkinsona wilkinsona removed the status: waiting-for-triage An issue we've not yet triaged label Sep 25, 2017
@wilkinsona wilkinsona self-assigned this Sep 25, 2017
@wilkinsona
Copy link
Member

Thanks, @vpavic. I've merged this into master.

@wilkinsona wilkinsona closed this Sep 25, 2017
@vpavic vpavic deleted the gh-9552 branch September 25, 2017 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider reinstating auto-configuration for Spring Session Mongo DB
7 participants