Skip to content

fix: no longer treats fluent methods as setters from record#3987

Open
mengnankkkk wants to merge 1 commit intoalibaba:mainfrom
mengnankkkk:hotfix/fix_3958
Open

fix: no longer treats fluent methods as setters from record#3987
mengnankkkk wants to merge 1 commit intoalibaba:mainfrom
mengnankkkk:hotfix/fix_3958

Conversation

@mengnankkkk
Copy link
Contributor

@mengnankkkk mengnankkkk commented Feb 6, 2026

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:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

final int methodNameLength = methodName.length();
boolean nameMatch = methodNameLength > 3 && (methodName.startsWith("set") || returnType == objectClass);
boolean nameMatch = methodNameLength > 3
&& (methodName.startsWith("set") || (!record && returnType == objectClass));
Copy link
Member

Choose a reason for hiding this comment

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

在这里的分支 再调用 isRecord(objectClass),避免普通set场景也有这个开销

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.

2 participants