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

Don't register a TypeSerializer for arbitrary Number subclasses #122

Merged
merged 1 commit into from
Aug 8, 2018

Conversation

Aaron1011
Copy link
Contributor

We have no way way to construct arbitrary subclasses of Number. By
registering a predicate that accepts only kown subclasses, we ensure
that users attempting to serialize an unknown Number subclass get a
proper exception, instead of a silent deserialization failure.

Fixes #121

We have no way way to construct arbitrary subclasses of Number. By
registering a predicate that accepts only kown subclasses, we ensure
that users attempting to serialize an unknown Number subclass get a
proper exception, instead of a silent deserialization failure.
@Aaron1011
Copy link
Contributor Author

I'd like to get this merged as soon as possible, as it fixes a fairly severe issue.

@Aaron1011 Aaron1011 requested review from kashike and lucko August 6, 2018 15:09
@lucko
Copy link
Contributor

lucko commented Aug 6, 2018

I'm fine with the change, but we need to make a decision about whether "backwards incompatible" bug fixes are being merged or not before 4.0. (see discussion in #120)

@Aaron1011
Copy link
Contributor Author

From my perspective, any plugin currently relying on NumberSerializer for custom Number types is already broken. IMHO, having an exception thrown is much better than continuing to silently lose data every time the config is loaded.

|| Short.class.equals(clazz)
|| Byte.class.equals(clazz)
|| Float.class.equals(clazz)
|| Double.class.equals(clazz);

Choose a reason for hiding this comment

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

I would have expected more types then this being supported by default. BigDecimal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My intent with this PR is just to fix the behavior of the existing serialized. We could probably add support for BigDecimal in another PR

@Aaron1011
Copy link
Contributor Author

@Zidane Thoughts on whether or not this should constitute a breaking change?

@Zidane
Copy link
Member

Zidane commented Aug 8, 2018

I am of the opinion it isn't breaking because it is inherently broken and it is our responsibility to mitigate that over a "technical break" with the exception being thrown.

@Aaron1011 Aaron1011 merged commit 7486a00 into master Aug 8, 2018
@ryantheleach
Copy link

@Aaron1011 @Zidane would #95 be considered in the same boat then? It prevents serialization of some DataContainers / NBT.

@lucko lucko deleted the fix/number-serializer branch August 9, 2018 07:23
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.

4 participants