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

Vendor JSON #1554

Merged
merged 76 commits into from
Nov 2, 2021
Merged

Vendor JSON #1554

merged 76 commits into from
Nov 2, 2021

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented Jun 23, 2021

📜 Description

This PR will be the baseline where further PRs will be merged into. Therefore it will stay in draft for a longer period of time.

Vendor

  • Add gson JSONReader and JSONWriter with needed files in vendor/gson folder
    • Document tag, commit hast and changes of added files
    • Add license in vendor/gson
    • Exclude vendor files from usual checks so we can keep the source/tests the same.
      • Easier to see updates when importing new files and also no risk of different behaviour.

Serialization

  • Adds JsonSerializable that models can implement to write json to a stream.
  • Adds JSONReader subclass JsonObjectWriter
    • Exposes method to call JsonObjectSerializer
      • Writes primitives, objects and serializable objects to the json stream.
      • Supports: null, boolean, int, long, double, String, Map, Collection, Array, JsonSerializable
      • Unknown objects are serialized with a string placeholder until we support reflection.
  • The JsonSerializable interface provides access to a unknown map which is serialized using JsonObjectSerializer
  • Exposes JsonSerializable as public API.

Deserialization

  • Adds JsonDeserializer that models can implement to read json to a stream.
  • Adds JSONWriter subclass JsonObjectReader.
    • Exposes method to call JsonObjectDeserializer.
      • Reads from the json stream and converts it to Java primitives & objects.
      • Supports: null, boolean, int, long, double, String, Map, List
  • The JsonDeserializer will take read all unknown fields and set then on the the deserialized object.

Example

  • UserFeedback implements serialization/deserialization using the new classes to illustrate the usage.

💡 Motivation and Context

Relates to #1537
Resolves #1733
Resolves #1497

  • Evaluate approach and plan further steps.

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

🔮 Next steps

This PR will stay open until everything is implemented.

@denrase denrase self-assigned this Jun 23, 2021
@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2021

Codecov Report

❗ No coverage uploaded for pull request base (6.x.x@c2a4506). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 6f0e0c5 differs from pull request most recent head 4ff9606. Consider uploading reports for the commit 4ff9606 to get more accurate results
Impacted file tree graph

@@           Coverage Diff            @@
##             6.x.x    #1554   +/-   ##
========================================
  Coverage         ?   80.91%           
  Complexity       ?     2815           
========================================
  Files            ?      204           
  Lines            ?    10340           
  Branches         ?     1367           
========================================
  Hits             ?     8367           
  Misses           ?     1491           
  Partials         ?      482           

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 c2a4506...4ff9606. Read the comment docs.

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

Would be nice to add a README.md to vendor/gson with a link to where we got it (their github I assume? but more importantly, the version (and commit sha), so we can easily diff/check if we need to update things.

Alternatively just add a comment to the top of the class:


https://github.com/google/gson/blob/f319c1b8e5ac1135ab253513f91d5ece6719cdf7/gson/src/main/java/com/google/gson/stream/JsonWriter.java

I see you've added the info to the file already under the header.

# Conflicts:
#	sentry/api/sentry.api
#	sentry/src/main/java/io/sentry/SentryEnvelopeHeader.java
#	sentry/src/main/java/io/sentry/protocol/DebugImage.java
#	sentry/src/main/java/io/sentry/protocol/MeasurementValue.java
#	sentry/src/main/java/io/sentry/protocol/SentryTransaction.java
@denrase denrase changed the title Vendor JSON Writer/Reader Vendor JSON Oct 4, 2021
@denrase
Copy link
Collaborator Author

denrase commented Oct 8, 2021

@marandaneto @maciejwalkowiak Think we are ready for an alpha release, i updated the changelog with the largest changes that this PR introduces. I did not merge in the main branch yet, as @marandaneto mentioned that we might point this against the 6.x.x branch.

@marandaneto marandaneto changed the base branch from main to 6.x.x October 11, 2021 13:48
@marandaneto
Copy link
Contributor

@marandaneto @maciejwalkowiak Think we are ready for an alpha release, i updated the changelog with the largest changes that this PR introduces. I did not merge in the main branch yet, as @marandaneto mentioned that we might point this against the 6.x.x branch.

@denrase I've targeted to the new branch, mind resolving the conflicts? thanks

# Conflicts:
#	CHANGELOG.md
#	sentry/api/sentry.api
#	sentry/src/test/java/io/sentry/SentryOptionsTest.kt
@marandaneto
Copy link
Contributor

Keep track of items for migration docs and changelog

looks like this is done or is there something missing?

@denrase
Copy link
Collaborator Author

denrase commented Oct 27, 2021

@marandaneto Don't remember what the original intent was. I did add some sentences in the changelog to describe the overall impact of the PR.

@denrase denrase marked this pull request as ready for review October 27, 2021 09:45
@marandaneto
Copy link
Contributor

@marandaneto Don't remember what the original intent was. I did add some sentences in the changelog to describe the overall impact of the PR.

just be sure that the changelog is up to date with all breaking changes.

See:

Serialization of objects with refection is currently not supported.

which is not the case anymore right.
Also, there are conflicting files now.

# Conflicts:
#	buildSrc/src/main/java/Config.kt
#	sentry/api/sentry.api
#	sentry/src/test/java/io/sentry/JsonSerializerTest.kt
#	sentry/src/test/java/io/sentry/SentryClientTest.kt
@denrase denrase requested a review from romtsn as a code owner October 27, 2021 13:41
@denrase
Copy link
Collaborator Author

denrase commented Oct 27, 2021

@marandaneto Merged in the current 6.x.x state and also updated the readme to reflect the reflection (🥁) state.

Copy link
Contributor

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

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

LGTM
thanks @denrase

@bruno-garcia
Copy link
Member

I'll do the honours then :D

@bruno-garcia bruno-garcia merged commit ad944b4 into 6.x.x Nov 2, 2021
@bruno-garcia bruno-garcia deleted the feat/vendor-json-writer-reader branch November 2, 2021 18:00
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.

sentry-java silently fails to deliver event when conflicting Gson class is on the classpath
4 participants