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

Tentative fix to deal with issues using generateJSONWithStreaming #247

Merged
merged 9 commits into from
Aug 16, 2023

Conversation

gabriele-tomassetti
Copy link
Member

I have an issue with serializing JSON with streaming for the RPG Parser. The issue is that when generating JSON with streaming there is essentially an alternative serialization process that is not affected by custom serializers and works a bit differently. This tentative fix effectively uses for the serialization with streaming the same methods for normal serialization.

I have also ensured that it is always used the gsonBuilder with the custom serializers.

However, I do not know if there was a specific reason for using alternative serialization methods for streaming serialization. Maybe I am missing something.

|{"#type":"com.strumenta.kolasu.serialization.Content","annidatedContent":
|{"#type":"com.strumenta.kolasu.serialization.Content","annidatedContent":
|{"#type":"com.strumenta.kolasu.serialization.Content","annidatedContent":null,"id":4},"id":3},"id":2}],
|[{"#type":"com.strumenta.kolasu.serialization.Content","id":1},
Copy link
Member

Choose a reason for hiding this comment

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

It would be useful to add several examples, using the flag shortClassNames set to false and to true

Copy link
Member

Choose a reason for hiding this comment

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

It would also be useful to have tests to load the examples, both with shortClassNames set to false and to true

Copy link
Member Author

Choose a reason for hiding this comment

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

Added more examples for generation, still working on deserialization tests.

val actualClass = try {
Class.forName(className)
} catch (ex: ClassNotFoundException) {
Class.forName(rawClass.`package`.name + "." + className)
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Member

Choose a reason for hiding this comment

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

Also, does not exist a method that check if a class exist without throwing an exception?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was just about to ask your opinion on this fix. It was needed to pass this test deserializeNodeFromStreamingWithShortNames. It seems that sometimes with simple names cannot find the right class.

I will check for that method.

Copy link
Member Author

Choose a reason for hiding this comment

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

There seems to be no such method. There is forName overload that does not throw an exception, but is Java 9+.

image

@gabriele-tomassetti gabriele-tomassetti merged commit 4e5947e into master Aug 16, 2023
3 checks passed
@ftomassetti ftomassetti deleted the jsonSerializationWithStreaming branch October 6, 2023 13:14
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.

2 participants