-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
bugfix: serialize the type of timestamp lost nano value #1443
bugfix: serialize the type of timestamp lost nano value #1443
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1443 +/- ##
============================================
+ Coverage 45.68% 45.7% +0.02%
Complexity 1664 1664
============================================
Files 345 345
Lines 12641 12666 +25
Branches 1588 1589 +1
============================================
+ Hits 5775 5789 +14
- Misses 6220 6228 +8
- Partials 646 649 +3
Continue to review full report at Codecov.
|
|
||
@Override | ||
public void serializeWithType(Timestamp timestamp, JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSerializer) throws IOException { | ||
gen.setCurrentValue(timestamp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to check the api to think is it necessary.
} catch (IOException e) { | ||
LOGGER.error("deserialize java.sql.Timestamp error : {}", e.getMessage(), e); | ||
} | ||
Timestamp timestamp = new Timestamp(arrayNode.get(0).asLong()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be in the catch block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, thanks for correct my mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okey to me
Ⅰ. Describe what this PR did
Jackson would use DateSerializer to handle java.sql.Timestamp(Timestamp extend from Date). So when java.sql.Timestamp has nano second, the digits would lost(java.util.Date dost not support nano second)
I provide customize serializer and deserializer. When serialize java.sql.Timestamp I convert it to a long array include fastTime and nanoSecond, look like this
finally use it rebuild java.sql.Timestamp when deserialize.
Ⅱ. Does this pull request fix one issue?
#1434
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews