fix: no longer treats fluent methods as setters from record#3987
Open
mengnankkkk wants to merge 1 commit intoalibaba:mainfrom
Open
fix: no longer treats fluent methods as setters from record#3987mengnankkkk wants to merge 1 commit intoalibaba:mainfrom
mengnankkkk wants to merge 1 commit intoalibaba:mainfrom
Conversation
wenshao
reviewed
Feb 7, 2026
| final int methodNameLength = methodName.length(); | ||
| boolean nameMatch = methodNameLength > 3 && (methodName.startsWith("set") || returnType == objectClass); | ||
| boolean nameMatch = methodNameLength > 3 | ||
| && (methodName.startsWith("set") || (!record && returnType == objectClass)); |
Member
There was a problem hiding this comment.
在这里的分支 再调用 isRecord(objectClass),避免普通set场景也有这个开销
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it?
Record 的 divide(Money) 返回自身,原逻辑把“返回类型=类自身”当作 fluent setter,导致 JSONB 解析时把 divide 当字段写入入
口并触发调用,从而抛出异常。Record 本质上是不可变载体,初始化应以构造器为主
我们应该对 Record 禁用 fluent setter
就是检测的时候跳过他
Summary of your change
Please indicate you've done the following: