Skip to content

Add: GenericException struct and ToGenericException converter - #397

Merged
wongoo merged 5 commits into
apache:masterfrom
Modo-me:feat/add-generic-exception
Jul 16, 2026
Merged

Add: GenericException struct and ToGenericException converter#397
wongoo merged 5 commits into
apache:masterfrom
Modo-me:feat/add-generic-exception

Conversation

@Modo-me

@Modo-me Modo-me commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What this PR does:
在 dubbo-go-hessian2 中新增 GenericException 定义

Which issue(s) this PR fixes:

Fixes apache/dubbo-go#3361 #388

Special notes for your reviewer:
实现了apache/dubbo-go#3361 里的阶段1,在dubbo-go-hessian2 中新增 GenericException结构体以及相关方法,根据原dubbo-go 侧的 GenericException定义,保持新增内容与此前apache/dubbo-go#3183 里引入的GenericException新增内容一致。
此改动对Java端兼容没有产生影响。

Does this PR introduce a user-facing change?:

NONE

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a Go-side GenericException representation to dubbo-go-hessian2 and a ToGenericException helper to normalize several decoded exception shapes (including java_exception.DubboGenericException, java_exception.Throwabler, and legacy string errors) into a consistent {ExceptionClass, ExceptionMessage} form.

Changes:

  • Introduce GenericException (implements error) to preserve Java exception class + message.
  • Add ToGenericException converter for multiple decoded exception variants.
  • Add legacy-string parsing helper for older exception string formats.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread generic_exception.go
Comment thread generic_exception.go
Comment thread generic_exception.go
Comment thread generic_exception.go
Comment thread generic_exception.go
Comment thread generic_exception.go
@Modo-me

Modo-me commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

parseLegacyException()中添加了保留java exception: <class> - <message>格式下的类名的逻辑,以及添加对parseLegacyException() ToGenericException()Error()各个分支情况的配套单测

@Modo-me

Modo-me commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

已修复CI错误:新增test里的import block没有拆开,未通过imports-formatter。现已修复

@Modo-me
Modo-me requested a review from AlexStocks July 9, 2026 10:36
@Modo-me

Modo-me commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

增加了ToGenericException()里对指针和接口分支的typed-nil检查,以及相应的回归测试

@tiltwind

tiltwind commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@Modo-me 问一下:

  1. 这个新增的exception 和原来这两个是什么关系? 什么情况下会用这个新增的? java_exception/dubbo_generic_exception.go, java_exception/exception.go
  2. 这个exception 需要序列化吗?是否需要补充序列化反序列化的 unit test ?

@tiltwind

Copy link
Copy Markdown
Contributor

查看了一下 apache/dubbo-go#3183 , GenericException 不参与序列化。
@Modo-me 建议代码中补充说明一下它的用途, 它和其他exception不一样, 其他exception都会注册并可能被序列化/反序列化处理。

@Modo-me

Modo-me commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

这个新增的exception来自于apache/dubbo-go#3183 而并非此次pr新增,在dubbo-go源码的protocol/dubbo/hessian2/hessian_response.go下。而这个pr旨在把这个exception的定义从dubbo-go迁移到dubbo-go-hessian2(根据apache/dubbo-go#3361 ), 同时补全了对应的单测

@tiltwind tiltwind left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wongoo wongoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wongoo
wongoo merged commit 28ed891 into apache:master Jul 16, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Migrate GenericException from dubbo-go to dubbo-go-hessian2

5 participants