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

schema creation and validation functions without panicing #794

Merged
merged 1 commit into from
Jun 23, 2022

Conversation

zzzming
Copy link
Contributor

@zzzming zzzming commented Jun 23, 2022

Fixes #793

#793

Motivation

This is an API improvement to avoid panic for any user recoverable error when a schema is created.

User should handle any codec error if the NewAvroSchema returns an error reference, although a user can still write a panic recovery procedure but that is not a standard way to do error handling.

Modifications

Introduce three additional functions to create JSON, Proto, and Avro schema with error returned without panic. The existing functions are kept for backward compatibility.

Verifying this change

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (yes)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)

New APIs are introduced to return any errors when schema codec creation fails. The legacy API are kept.

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / GoDocs / not documented)
  • If a feature is not applicable for documentation, explain why?
  • If a feature is not documented yet in this PR, please create a followup issue for adding the documentation

Copy link

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Lgtm

Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

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

LGTM

@merlimat merlimat merged commit b392b9c into apache:master Jun 23, 2022
@merlimat merlimat added this to the v0.9.0 milestone Jun 23, 2022
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.

NewAvroSchema's error lead to panic
4 participants