Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

修改 DateCodec 判断 dateFormat 长度的逻辑 #3362

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

vdiskg
Copy link

@vdiskg vdiskg commented Jul 24, 2020

#3361
修改 DateCodec 判断 dateFormat 长度的逻辑,以解决 dateFormatPattern 当中含有 [单引号、Z ] 等导致的长度判断错误

@CLAassistant
Copy link

CLAassistant commented Jul 24, 2020

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2020

Codecov Report

Merging #3362 into master will decrease coverage by 0.00%.
The diff coverage is 87.50%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3362      +/-   ##
============================================
- Coverage     80.47%   80.46%   -0.01%     
  Complexity     7454     7454              
============================================
  Files           157      157              
  Lines         27840    27847       +7     
  Branches       6708     6708              
============================================
+ Hits          22404    22408       +4     
- Misses         3423     3425       +2     
- Partials       2013     2014       +1     
Impacted Files Coverage Δ Complexity Δ
...com/alibaba/fastjson/parser/DefaultJSONParser.java 87.96% <85.71%> (-0.02%) 323.00 <1.00> (+1.00) ⬇️
...ava/com/alibaba/fastjson/serializer/DateCodec.java 92.89% <100.00%> (+0.50%) 50.00 <0.00> (ø)
...com/alibaba/fastjson/serializer/SerialContext.java 82.69% <0.00%> (-3.85%) 21.00% <0.00%> (-1.00%)
...main/java/com/alibaba/fastjson/util/FieldInfo.java 86.62% <0.00%> (-0.34%) 99.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 bd535c3...ac85869. Read the comment docs.

private void test(String format) {
Demo demo = new Demo();
demo.setDate(new java.util.Date());
JSON.DEFFAULT_DATE_FORMAT = format;
Copy link
Contributor

Choose a reason for hiding this comment

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

你这样不是线程安全的诶,其实从全局角度来说我觉得还是在字段上面定义格式会更香一点

Copy link
Author

Choose a reason for hiding this comment

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

你这样不是线程安全的诶,其实从全局角度来说我觉得还是在字段上面定义格式会更香一点

我认为全局的格式应当是在初始化阶段设置的,运行期间不应该去改这个值,test里面这么做仅仅是为了验证一下这两种情况都能正确处理而已,实际使用的时候肯定是定死一个值再也不会去改它的。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants