Skip to content

Refactor userTypeResolver construction into separate method #1297

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

akhaku
Copy link
Contributor

@akhaku akhaku commented Aug 20, 2022

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

This allows for easy overriding, for example in case you
wish to use a different implementation.
@@ -260,4 +255,8 @@ protected KeyspacePopulator keyspacePopulator() {
protected ByteArrayResource scriptOf(String content) {
return new ByteArrayResource(content.getBytes());
}

protected UserTypeResolver userTypeResolver(CqlSession cqlSession) {
return new SimpleUserTypeResolver(cqlSession, CqlIdentifier.fromCql(getKeyspaceName()));
Copy link
Contributor Author

@akhaku akhaku Aug 20, 2022

Choose a reason for hiding this comment

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

I should mention that really what I'm trying to do is allow getKeyspaceName() to be null, but right now the docs in AbstractSessionConfiguration are explicit that it should be non-null... We already override the session factory bean and the only piece that's causing problems with the null keyspace right now is the UserTypeResolver, so moving the constructor to a protected method will let me override it without trying to unravel getKeyspace()'s nullability in AbstractSessionConfiguration

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for merging and polishing! I'm not entirely sure what you're getting at, are you just saying that this change is reasonable or that we should explore making a change in spring-boot's CassandraDataAutoConfiguration as well? Or are you saying it would be worth exploring allowing getKeyspace to return null?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 20, 2022
@akhaku
Copy link
Contributor Author

akhaku commented Sep 1, 2022

@mp911de I'd love a blessing if you have a moment! Pretty small change, shouldn't have any impact.

@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 1, 2022
@mp911de mp911de added this to the 3.4.3 (2021.2.3) milestone Sep 1, 2022
mp911de pushed a commit that referenced this pull request Sep 1, 2022
This allows for easy overriding, for example in case you
wish to use a different implementation.

See #1297
mp911de added a commit that referenced this pull request Sep 1, 2022
Add Javadoc.

Closes #1297
mp911de pushed a commit that referenced this pull request Sep 1, 2022
This allows for easy overriding, for example in case you
wish to use a different implementation.

See #1297
@mp911de mp911de closed this in 43b964f Sep 1, 2022
@mp911de
Copy link
Member

mp911de commented Sep 1, 2022

Thank you for your contribution. That's merged, polished, and backported now.

@akhaku akhaku deleted the userTypeResolver branch September 2, 2022 05:06
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.

3 participants