-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Avoid having TypeConverter
defined as beans
#10315
Conversation
Strange, what is defining it to be initiated at the runtime:
|
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.
What is the motivation for this change?
But more importantly, we need to update the documentation. We currently say:
You can register additional converters for types not supported by Micronaut by defining beans that implement the TypeConverter interface
However, this PR indicates the recommended approach is to:
Create a class, not a bean, implementing TypeConveterRegistrar
.
Register the converter in that class.
List the TypeConverterRegistrar
implementation in src/main/resources/META-INF/services/io.micronaut.core.convert.TypeConverterRegistrar
so that it is loaded later via Java SPI.
Moreover, removing the beans SameSiteConverter
and CorsOriginConveter
and making them @Internal
could be considered a breaking change.
http-server/src/main/java/io/micronaut/http/server/ConvertersRegistrar.java
Outdated
Show resolved
Hide resolved
Registering the converter using the SPI versus finding beans should be faster for the startup; having fewer beans is also a plus. The only reason to have converters as beans is if you need to inject something external. I'm not sure what the point of having those public. Now I tried to disable |
Or maybe we lack test coverage. |
What do you mean by |
Like the bean context or something from it. |
I think it's used in the multiple CORS configuration and we should have tests for it. |
A TCK test fails: JUnit Platform Suite:HTTP Server TCK for Netty:JUnit Jupiter:CorsSimpleRequestTest:corsSimpleRequestForLocalhostCanBeAllowedViaRegexConfiguration() |
@dstepanov can you please update the documentation
|
It's strange that it would fail only in native |
This reverts commit 121ee26.
@sdelamo I have corrected docs |
Quality Gate failedFailed conditions 68.8% Coverage on New Code (required ≥ 70%) |
No description provided.