You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/08/12 16:17:41 UTC

[GitHub] [dubbo] liufeiyu1002 commented on issue #10415: The dubbo method parameter validation exception message is swallowed by ValidationException

liufeiyu1002 commented on issue #10415:
URL: https://github.com/apache/dubbo/issues/10415#issuecomment-1213289750

   原因就是 `ConstraintViolationImpl` 会发生序列化问题。我想到的解决办法
   1. 消费者端引入 ValidationFilter 和  Validation 进行前置校验,非法请求直接在消费者端就拦截掉 (不需要开发 只需要消费者端引入就可以)
   2. 官方在 Validation 校验发生异常的时候 提供一个可由用户自定义扩展的异常信息包装的处理
   ![image](https://user-images.githubusercontent.com/32605119/184399382-d3a6eb97-0676-4a9e-8569-134b5cc91d95.png)
   如图 可以调用扩展 (通过静态类配置 或者 是spi扩展)对异常信息进行包装,框架提供默认扩展为 ` new ValidationException(e.getMessage())`  即仅返回异常消息,用户可以针对自己的需求,对`ConstraintViolation` 中的信息进行二次封装成可序列化的类   例如:#10415 这种实现


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org