-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Validate Spring Session database initializer configuration #6649
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
Validate Spring Session database initializer configuration #6649
Conversation
Jdbc jdbcProperties = this.sessionProperties.getJdbc(); | ||
if (jdbcProperties.getInitializer().isEnabled()) { | ||
if (Jdbc.DEFAULT_SCHEMA_LOCATION.equals(jdbcProperties.getSchema()) && | ||
!Jdbc.DEFAULT_TABLE_NAME.equals(jdbcProperties.getTableName())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no reason to move that business in @PostConstruct
. You're not using the state of the (Configuration) class but solely the state of SessionProperties
so you could just as well move that in SessionProperties
itself if that's an invalid state (more on this later).
This commit adds Spring Session JDBC configuration validation that disables database initializer in case custom table name is configured with default schema.
394f74c
to
4d2d7b0
Compare
I've updated the PR according to feedback. |
This commit adds Spring Session JDBC configuration validation that disables database initializer in case custom table name is configured with default schema. See gh-6649
* pr/6649: Polish contribution Validate Spring Session database initializer configuration
Thanks @vpavic, this is now merged in master. |
This PR adds Spring Session JDBC configuration validation that disables database initializer in case custom table name is configured with default schema.
Currently, it is possible to set custom table name but leave default schema configuration property. This will either result in an error in runtime since expected table (with custom name) won't be found, or, if user has set up the correct table by some other means, with created unused table.
In both cases the correct approach would be to fail fast and indicate invalid configuration.