-
Notifications
You must be signed in to change notification settings - Fork 839
Add forward compatibility to TaggedFieldSerializer in issue #352. #365
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
Conversation
LGTM. @NathanSweet @romix What do you think? |
+1 |
@levyfan Can you adjust javadoc and the README to mention this improvement? I think then it's ok to merge. Thanks! |
Thanks @magro , please have a review. |
Great to have this feature soon :) |
I've thought about the way of configuration and think we should choose a different approach: https://groups.google.com/forum/#!topic/kryo-users/G16daCijbWo So if we merge this now the api might be changed before the release, or we wait until this is clarified / changed. Apart from this, there are things currently holding back a release: https://groups.google.com/forum/#!topic/kryo-users/Fg0yCqZts6E |
@magro @levyfan class NewRoot {
@TaggedFieldSerializer.Tag(0)
field b;
@TaggedFieldSerializer.Tag(1)
field a;
}
class Root {
@TaggedFieldSerializer.Tag(0)
field b;
} If the serializer writes a byte stream with type NewRoot then it can't be read correctly into an object of type Root. However if alphabetical order is maintained: class NewRoot {
@TaggedFieldSerializer.Tag(0)
field b;
@TaggedFieldSerializer.Tag(1)
field c;
}
class Root {
@TaggedFieldSerializer.Tag(0)
field b;
} The stream can be read correctly into an object of type Root . Here's a file with tests |
@magro @psmarcos fixed. |
The `Kryo` class is more and more used for "global" configuration of serializers like `FieldSerializer` etc (here's another PR: EsotericSoftware#365). The semantics of such settings and especially for which serializer it's applied can often only be clarified via documentation. This change introduces a `FieldSerializerConfig` class that encapsulates configuration for `FieldSerializer`. It allows to configure settings for all `FieldSerializer` instances created via `Kryo.getFieldSerializerConfig`. `Kryo.asmEnabled` might be used by different serializers, but because until now it was only used by `FieldSerializer` this setting is also kept in `FieldSerializerConfig`. `Kryo.set/getAsmEnabled` is marked as deprecated with a hint to use `getFieldSerializerConfig` instead - this is done to stay binary compatible. `Kryo.setCopyTransient` is removed because it was introduced after the latest release 3.0.3 and therefore not yet a published/released. Now `Kryo.getFieldSerializerConfig.setCopyTransient` has to be used. If this is considered to be merged then EsotericSoftware#365 should also follow this approach.
The `Kryo` class is more and more used for "global" configuration of serializers like `FieldSerializer` etc (here's another PR: EsotericSoftware#365). The semantics of such settings and especially for which serializer it's applied can often only be clarified via documentation. This change introduces a `FieldSerializerConfig` class that encapsulates configuration for `FieldSerializer`. It allows to configure settings for all `FieldSerializer` instances created via `Kryo.getFieldSerializerConfig`. On each `FieldSerializer` the config can be changed/overridden, this is done directly on the serializer (instead e.g. requiring to invoke `fieldSerializer.getConfig.setSomeThing`) to stay binary compatible and because forcing to use the config here does not seem to be of much value. The `FieldSerializer` internally uses the config object so that any further settings are directly added to `FieldSerializerConfig` and there's only a single place to keep config settings. `Kryo.asmEnabled` might be used by different serializers, but because until now it was only used by `FieldSerializer` this setting is also kept in `FieldSerializerConfig`. `Kryo.set/getAsmEnabled` is marked as deprecated with a hint to use `getFieldSerializerConfig` instead - this is done to stay binary compatible. `Kryo.setCopyTransient` is removed because it was introduced after the latest release 3.0.3 and therefore not yet a published/released. Now `Kryo.getFieldSerializerConfig.setCopyTransient` has to be used. If this is considered to be merged then EsotericSoftware#365 should also follow this approach.
The `Kryo` class is more and more used for "global" configuration of serializers like `FieldSerializer` etc (here's another PR: EsotericSoftware#365). The semantics of such settings and especially for which serializer it's applied can often only be clarified via documentation. This change introduces a `FieldSerializerConfig` class that encapsulates configuration for `FieldSerializer`. It allows to configure settings for all `FieldSerializer` instances created via `Kryo.getFieldSerializerConfig`. On each `FieldSerializer` the config can be changed/overridden, this is done directly on the serializer (instead e.g. requiring to invoke `fieldSerializer.getConfig.setSomeThing`) to stay binary compatible and because forcing to use the config here does not seem to be of much value. The `FieldSerializer` internally uses the config object so that any further settings are directly added to `FieldSerializerConfig` and there's only a single place to keep config settings. `Kryo.asmEnabled` might be used by different serializers, but because until now it was only used by `FieldSerializer` this setting is also kept in `FieldSerializerConfig`. `Kryo.set/getAsmEnabled` is marked as deprecated with a hint to use `getFieldSerializerConfig` instead - this is done to stay binary compatible. `Kryo.setCopyTransient` is removed because it was introduced after the latest release 3.0.3 and therefore not yet a published/released. Now `Kryo.getFieldSerializerConfig.setCopyTransient` has to be used. If this is considered to be merged then EsotericSoftware#365 should also follow this approach.
@magro please have a review |
Because the |
* </p> | ||
* | ||
* @param ignoreUnknownTags if true, unknown field tags will be ignored. Otherwise KryoException will be thrown */ | ||
public void setIgnoreUnknownTags (boolean ignoreUnknownTags) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go into TaggedFieldSerializer
.
Thanks @magro , please have a review |
@@ -70,7 +70,7 @@ | |||
/** type variables declared for this type */ | |||
final TypeVariable[] typeParameters; | |||
final Class componentType; | |||
private final FieldSerializerConfig config; | |||
final FieldSerializerConfig config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semantically this should be protected probably, sorry that I haven't seen this last time.
LGTM, only the one protected seems to be left. Can you squash commits to a single one? Then I'll merge. Thanks! |
Hi @magro , please have a review |
Great, thanks a lot! |
Add forward compatibility to TaggedFieldSerializer in issue #352.
Add ignoreUnknownTags flag in Kryo configuration. If it is set, TaggedFieldSerializer will ignore unknown field tags in input stream. Otherwise a KryoException will be thrown.