You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "wangj-un (via GitHub)" <gi...@apache.org> on 2023/05/24 08:59:08 UTC

[GitHub] [dubbo] wangj-un opened a new issue, #12393: 版本: Dubbo3.2.1 抛出自定义异常类,报反序列化异常

wangj-un opened a new issue, #12393:
URL: https://github.com/apache/dubbo/issues/12393

   <!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy -->
   
   - [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version: 3.2.1
   * Operating System version: xxx
   * Java version: 1.8.0_261
   
   ### Steps to reproduce this issue
   
   1. xxx
   2. xxx
   3. xxx
   
   Pls. provide [GitHub address] to reproduce this issue.
   
   ### Expected Behavior
   
   <!-- What do you expect from the above steps?-->
   
   ### Actual Behavior
   
   <!-- What actually happens? -->
   
   If there is an exception, please attach the exception trace:
   异常栈信息:
   ![image](https://github.com/apache/dubbo/assets/50893903/52c79965-2913-45d5-b905-2860ea658556)
   异常类定义如下:
   public class BusinessException extends ApplicationException{
   
       public BusinessException() {
           super(GlobalStatusEnum.BUSINESS_EXCEPTION);
       }
   
       public BusinessException(String message) {
           super(GlobalStatusEnum.BUSINESS_EXCEPTION.getCode(), message);
       }
   
       public BusinessException(String code, String message) {
           super(code, message);
       }
   
       public BusinessException(GlobalStatusEnum globalStatus) {
           super(globalStatus);
       }
   }
   
   public class ApplicationException extends RuntimeException {
   
       private static final long serialVersionUID = -6118529754180362427L;
   
       /**
        * 异常码
        */
       private final String code;
   
       public String getCode() {
           return code;
       }
   
       public ApplicationException() {
           super(GlobalStatusEnum.SERVER_ERROR.getMessage());
           this.code = GlobalStatusEnum.SERVER_ERROR.getCode();
       }
   
       public ApplicationException(String code, String message) {
           super(message);
           this.code = code;
       }
   
       public ApplicationException(String message) {
           super(message);
           this.code = GlobalStatusEnum.SERVER_ERROR.getCode();
       }
   
       public ApplicationException(GlobalStatusEnum globalStatusEnum) {
           super(globalStatusEnum.getMessage());
           this.code = globalStatusEnum.getCode();
       }
   
       public ApplicationException(Exception exception) {
           super(exception.getMessage());
           this.code = exception instanceof ApplicationException ? ((ApplicationException)exception).getCode() : GlobalStatusEnum.BUSINESS_EXCEPTION.getCode();
       }
   }
   
   ```
   


-- 
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.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


[GitHub] [dubbo] wangj-un closed issue #12393: 版本: Dubbo3.2.1 抛出自定义异常类,报反序列化异常

Posted by "wangj-un (via GitHub)" <gi...@apache.org>.
wangj-un closed issue #12393: 版本: Dubbo3.2.1 抛出自定义异常类,报反序列化异常
URL: https://github.com/apache/dubbo/issues/12393


-- 
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


[GitHub] [dubbo] conghuhu commented on issue #12393: 版本: Dubbo3.2.1 抛出自定义异常类,报反序列化异常

Posted by "conghuhu (via GitHub)" <gi...@apache.org>.
conghuhu commented on issue #12393:
URL: https://github.com/apache/dubbo/issues/12393#issuecomment-1568621204

   这是因为Dubbo3.2之后默认为 STRICT 严格检查级别。
   STRICT 严格检查:禁止反序列化所有不在允许序列化列表(白名单)中的类。
   
   你需要在resource下定义以下可信文件,将您的自定义类名加进去。
   ![image](https://github.com/apache/dubbo/assets/56248584/f4c9f4e7-00f8-4b52-873e-6cbc6c91740f)
   
   详情可看官网文档:[Dubbo类检查机制](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/advanced-features-and-usage/security/class-check/)
   
   最后效果(consumer):
   ![image](https://github.com/apache/dubbo/assets/56248584/f02eda6d-af88-4885-ae0c-664c2f08bff4)
   


-- 
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