This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
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.
fix #2488 #2385 #2722
修复两个问题
以美元符号($)开头的属性,序列化和反序列都不解析,因为当前的逻辑是通过get/set/is方法名来解析propertyName,其中只对大写字母开头、'_'开头和'f'开头的属性做了特殊判断,但没有考虑到去掉get/set/is前缀后方法名与属性名称相同的场景,比如
setage()
对应age属性(此前只能识别setAge()
)修复方案:在所有解析propertyName的逻辑中,若匹配大写字母开头、'_'开头和'f'开头失败时(进入else分支),尝试直接去掉get\set\is前缀,并且不做任何大小写转换去获取field
以下划线符号(_)开头,序列化出来的字符串丢失了下划线符号(_),因为解析propertyName逻辑中为了支持
get_set_Test.java
用例中的特殊下划线场景,直接去掉了下划线。修复方案:在下划线开头的特殊处理分支中增加逻辑,如果去掉下划线获取不到field,就尝试加上下划线去获取(如果还是获取不到就还原回去掉下划线的属性名,以减少本次改动带来的影响)