Skip to content
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

Kotlin Configuration DSL: Use reified types wherever a class is used as a parameter #8697

Closed
gonozalviii opened this issue Jun 16, 2020 · 3 comments · Fixed by #8771
Closed
Assignees
Labels
in: config An issue in spring-security-config status: ideal-for-contribution An issue that we actively are looking for someone to help us with type: enhancement A general enhancement
Milestone

Comments

@gonozalviii
Copy link

Expected Behavior

Functions that take a class as a parameter could be written in a idiomatic kotlin way like
addFilterAt<BasicAuthenticationFilter>(myFilter) also removing some noise.

Current Behavior

The current version of the function takes a java class as a parameter:
addFilterAt(myFilter, BasicAuthenticationFilter::class.java)

Context

When using any Kotlin DSL I don't expect to pass a java class as a parameter. Normally you would pass Kotlins KClass (BasicAuthenticationFilter::class) or use the even more idiomatic way of with a generic reified type. That's also embraced in other parts of Spring like the RestTemplate that for example has an extension functions for post (postForObject(url)).

@gonozalviii gonozalviii added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Jun 16, 2020
@eleftherias eleftherias added in: config An issue in spring-security-config and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 22, 2020
@eleftherias
Copy link
Contributor

Thanks for the report @gonozalviii! Would you be interested in submitting a PR for this?

@eleftherias eleftherias added the status: ideal-for-contribution An issue that we actively are looking for someone to help us with label Jun 22, 2020
@gonozalviii
Copy link
Author

Yes I can create a PR.

I assume the new functions should be added, and the old functions should be kept?

@eleftherias
Copy link
Contributor

@gonozalviii Yes, please keep the old functions for backwards compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: config An issue in spring-security-config status: ideal-for-contribution An issue that we actively are looking for someone to help us with type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants