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 serialization of Long inside of Request.data #2051
Conversation
} else if (object instanceof Float) { | ||
return object; | ||
} else if (object instanceof Double) { | ||
} else if (object instanceof Number) { |
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'm a bit confused why do we have special handling for byte and short and don't for others?
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.
Also not sure, why they are converted to Integer
. I'll try to find out.
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.
There's a test that fails if the special handling is removed. I've added another test that serializes then deserializes the output again. It seems to work without the special handling. But I'm not sure if there's a reason it's there.
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.
Please check with @denrase
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 guess i had the wrong expectation in the test, therefore the cast to int
. So this part should be correct now.
The intent here was to return the string, characters cast to string and all Java primitives (of which i forgot Long
apparently 🤦), as those are pretty much the leaves of the tree we are trying to traverse.
Number is a superclass to more than those primitives, but i'm not sure what the impact would be if we for example encounter something like DoubleAccumulator
?
https://docs.oracle.com/javase/8/docs/api/java/lang/Number.html
Maybe we should introduce a method Bool isPrimitive(Object object)
(and also check for Long
) to keep the original intent and not have to think about those other Number
subclasses.
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.
Just tested DoubleAccumulator
, BigInteger
and BigDecimal
locally. All of them worked. Didn't test all Number
subtypes but I'd say risk is pretty low here.
Codecov Report
@@ Coverage Diff @@
## 6.x.x #2051 +/- ##
========================================
Coverage ? 80.88%
Complexity ? 3170
========================================
Files ? 228
Lines ? 11716
Branches ? 1574
========================================
Hits ? 9476
Misses ? 1649
Partials ? 591 Continue to review full report at Codecov.
|
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
- Fix serialization of Long inside of Request.data ([#2051](https://github.com/getsentry/sentry-java/pull/2051)) If none of the above apply, you can opt out of this check by adding |
📜 Description
Handle
Number
insideJsonReflectionObjectSerializer
which includesLong
.💡 Motivation and Context
Fix #2044
💚 How did you test it?
Unit Test
📝 Checklist
🔮 Next steps