Skip to content

Serializable Wrappers #1156

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

Merged
merged 13 commits into from
Jun 10, 2024
Merged

Serializable Wrappers #1156

merged 13 commits into from
Jun 10, 2024

Conversation

scottf
Copy link
Contributor

@scottf scottf commented Jun 3, 2024

It's impractical to make configuration object serializable because it would make any changes like an addition of a field NOT backward compatible because the serialVersionUID would change, versioning the entire class, requiring a semver major version.

So instead,

  • relevant classes are ensured to be JsonSerializable if not already
  • builders are modified to accept json.
  • wrapper classes have been added that use the json to serialize and deserialize

@somratdnutanix
Copy link

Thanks @scottf .
The changes look solid.
Please ensure the tests cover all possible configurations, including edge cases, for both serialization and deserialization. We can include tests for error scenarios such as handling invalid JSON input.
Once its merged, I can refactor the connector code to use this instead of what we have used now.

@scottf
Copy link
Contributor Author

scottf commented Jun 6, 2024

Please ensure the tests cover all possible configurations, including edge cases, for both serialization and deserialization

What edge cases? If the json is invalid, it will throw a parse error. Also since I run the json through the builder invalid data should be caught there but...I don't think it's necessary to handle edge cases. The expectation is that the json comes from the objects' toJson method so should never be invalid. The unit tests all test round trip of the serialization.
Is there something I am missing?

@somratdnutanix
Copy link

Okay, then it should be pretty much covered @scottf.
Looks good. 👍

@scottf scottf changed the title Serializable Consumer Configuration Serializable Wrappers Jun 10, 2024
@scottf scottf merged commit affe6be into main Jun 10, 2024
2 checks passed
@scottf scottf deleted the serializable-consumer-configuratuon branch June 10, 2024 15:19
@somratdnutanix
Copy link

It's impractical to make configuration object serializable because it would make any changes like an addition of a field NOT backward compatible because the serialVersionUID would change, versioning the entire class, requiring a semver major version.

So instead,

  • relevant classes are ensured to be JsonSerializable if not already
  • builders are modified to accept json.
  • wrapper classes have been added that use the json to serialize and deserialize

thanks @scottf for this.
we won't have to use proxy pattern for each field now.
will refactor our connector code and be back with you.

@somratdnutanix
Copy link

somratdnutanix commented Jun 11, 2024

got these warning when I tried to build Maven locally, mostly due to missing Javadoc comments, @scottf .

> Task :javadoc ConsumerConfiguration.java:697: warning: no @param for json public Builder json(String json) throws JsonParseException { ^ ConsumerConfiguration.java:697: warning: no @return public Builder json(String json) throws JsonParseException { ^ ConsumerConfiguration.java:697: warning: no @throws for io.nats.client.support.JsonParseException public Builder json(String json) throws JsonParseException { ^ ConsumerConfiguration.java:704: warning: no @param for v public Builder jsonValue(JsonValue v) { ^ ConsumerConfiguration.java:704: warning: no @return public Builder jsonValue(JsonValue v) { ^ ConsumerConfiguration.java:650: warning: no @param for cc public Builder(ConsumerConfiguration cc) { ^ BaseConsumeOptions.java:124: warning: no @param for v public B jsonValue(JsonValue v) { ^ BaseConsumeOptions.java:124: warning: no @return public B jsonValue(JsonValue v) { ^ 8 warnings

@scottf
Copy link
Contributor Author

scottf commented Jun 11, 2024

got these warning when I tried to build Maven locally, mostly due to missing Javadoc comments, @scottf
Warnings right? I'll fix the java doc, thanks

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