This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
修复在ParserConfig中指定String.class(及一些较基础类型class)的自定义反序列化器无效的问题 #2670
Open
Omega-Ariston
wants to merge
2
commits into
alibaba:master
Choose a base branch
from
Omega-Ariston:fix-issue1875+2624
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
Codecov Report
@@ Coverage Diff @@
## master #2670 +/- ##
===========================================
- Coverage 81.14% 80% -1.14%
- Complexity 7021 7059 +38
===========================================
Files 143 145 +2
Lines 26258 26713 +455
Branches 6276 6373 +97
===========================================
+ Hits 21307 21373 +66
- Misses 3129 3499 +370
- Partials 1822 1841 +19
Continue to review full report at Codecov.
|
Omega-Ariston
force-pushed
the
fix-issue1875+2624
branch
from
August 29, 2019 06:14
9051efb
to
003a19e
Compare
Codecov Report
@@ Coverage Diff @@
## master #2670 +/- ##
============================================
- Coverage 80.13% 80.00% -0.13%
+ Complexity 7071 7059 -12
============================================
Files 145 145
Lines 26704 26713 +9
Branches 6372 6373 +1
============================================
- Hits 21399 21373 -26
- Misses 3473 3499 +26
- Partials 1832 1841 +9
Continue to review full report at Codecov.
|
@Omega-Ariston 在1.2.69+的版本中,这个全局的功能又失效了... |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
修复 #2624 #1875 中提到的通过ParserConfig自定义反序列化String.class不起作用的问题。
根因是fastjson针对String.class, Long.class这类比较基础的类型做了优化,有提供默认的反序列化器,但在判断用户是否针对这些类型自定义了反序列化器的逻辑上有缺陷(只判断了通过注解指定的方式,而没有判断通过ParserConfig配置的方式)
这里在
DefaultFieldDeserializer
的构造函数中对ParserConfig中取出的反序列化器进行了额外判断,如果不是默认的反序列化器(而是用户自己定义的),则把DefaultFieldDeserializer.customDeserializer
属性设置为true,触发使用自定义反序列化器的逻辑。而在此之前,用户只能通过注解的方式将这个属性设置为true。为了判断当前反序列化器是否为默认反序列化器,在ParserConfig中存储了一个静态的Map,用于存储各个基础类型的默认反序列化器,方便进行比较。