Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 3050 属性Feature.InitStringFieldAsEmpty导致没有使用双引号的数值型value解析错误 #3142

Merged
merged 5 commits into from
May 16, 2020

Conversation

J-Cod3r
Copy link
Contributor

@J-Cod3r J-Cod3r commented May 3, 2020

fixed #3050

解析json时如果设置属性 Feature.InitStringFieldAsEmpty,ASMDeserializerFactory 生成的字节码会将String类型的字段值设为空字符串并标记该字段的flag为 parse(相当于默认所有String类型的flag为parse)。

如果此时解析如下json串:

String jsonStr = "{"name":5, "address":"beijing", "id":"100", "age":10}";

由于name对应的bean字段是String类型,但name的value没有使用双引号,导致当执行 scanFieldString 方法时取不到name的值,而后续的 smartMatch 方法由于String类型字段的flag已被设置为parse,会导致找不到对应的 fieldDeserializer,从而导致解析结果错误。

@CLAassistant
Copy link

CLAassistant commented May 3, 2020

CLA assistant check
All committers have signed the CLA.

@wenshao
Copy link
Member

wenshao commented May 5, 2020

你确认这个改动能够跑过所有testcase?

@wenshao wenshao self-requested a review May 5, 2020 05:55
@J-Cod3r
Copy link
Contributor Author

J-Cod3r commented May 5, 2020

你确认这个改动能够跑过所有testcase?

刚本地跑了遍所有的测试,确实影响了其他的测试案例,我的这个改动不是正确的选择

@codecov-io
Copy link

codecov-io commented May 5, 2020

Codecov Report

Merging #3142 into master will decrease coverage by 0.00%.
The diff coverage is 66.66%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3142      +/-   ##
============================================
- Coverage     80.40%   80.39%   -0.01%     
+ Complexity     7309     7307       -2     
============================================
  Files           155      155              
  Lines         27369    27372       +3     
  Branches       6561     6562       +1     
============================================
  Hits          22006    22006              
- Misses         3457     3458       +1     
- Partials       1906     1908       +2     
Impacted Files Coverage Δ Complexity Δ
...json/parser/deserializer/JavaBeanDeserializer.java 79.80% <66.66%> (-0.24%) 307.00 <0.00> (ø)
...main/java/com/alibaba/fastjson/util/FieldInfo.java 86.20% <0.00%> (ø) 90.00% <0.00%> (-1.00%)
...ava/com/alibaba/fastjson/parser/JSONLexerBase.java 71.32% <0.00%> (ø) 827.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec83a69...0cb97f4. Read the comment docs.

@J-Cod3r
Copy link
Contributor Author

J-Cod3r commented May 5, 2020

代码已修改,问题 #2387 可能也与本问题相关,相关testcase已修复

@J-Cod3r J-Cod3r marked this pull request as draft May 13, 2020 12:57
@J-Cod3r J-Cod3r marked this pull request as ready for review May 13, 2020 13:05
@wenshao wenshao merged commit dde6b99 into alibaba:master May 16, 2020
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.

【bug】1.2.66 版本,添加属性 Feature.InitStringFieldAsEmpty 解析结果错误
4 participants