aofall commented on PR #13923:
URL: https://github.com/apache/dubbo/pull/13923#issuecomment-2051528745
> A more conscise way is to use
`org.apache.dubbo.common.extension.Activate#onClass` and create two filter for
`javax` and `jakarta`
@AlbumenJ I try to use `Activate#onClass` on two filter class for `javax`
and `jakarta`, but found another problem.
The Validation was mark the `jvalidation` by default extension by the
`@SPI("jvalidation")` annotation on class.
https://github.com/apache/dubbo/blob/6b3f54383f4b6102215e33ea879a389dff0fd1eb/dubbo-filter/dubbo-filter-validation/src/main/java/org/apache/dubbo/validation/Validation.java#L28
If use `@Activate(onClass = "javax.validation.Validation")` on the
`org.apache.dubbo.validation.support.jvalidation.JValidation` class, this
extension will not loaded, because the declare default extension it will throw
the IllegalStateException(No such extension jvalidation....) in
`org.apache.dubbo.common.extension.ExtensionLoader#createExtension`
https://github.com/apache/dubbo/blob/6b3f54383f4b6102215e33ea879a389dff0fd1eb/dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java#L773
If remove the default extension declared in
`org.apache.dubbo.validation.Validation`,
`org.apache.dubbo.validation.Validation#getValidator` will attempt to load the
extension with the corresponding name from the relevant configurations like
`dubbo.consumer.validation` and `dubbo.provider.validation` , but the official
document of
[provider](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/config/properties/#provider)
and
[consumer](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/config/properties/#consumer)
defines the parameter type of `validation` as Boolean, it's unexpect for
[dubbo-samples](https://github.com/apache/dubbo-samples/blob/f82f23f3fbb4a47eaeba8b7eecfef85318adf6db/2-advanced/dubbo-samples-validation/src/main/resources/application.yml#L27)
As long as fill in any characters into `dubbo.provider/consumer.validation`
configuration, verification will be enabled and loaded the default extension
`jvalidation`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]