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

Portable Serialization incompatible class definition when nested portables used #12733

Closed
sancar opened this issue Mar 28, 2018 · 0 comments
Closed

Comments

@sancar
Copy link
Member

@sancar sancar commented Mar 28, 2018

Portable serialization is mistakenly reporting incompatible class-definitions when nested portables are used in certain scenarios.
Details of failed scenario are as follows:
Let's say, we have two Portables: Parent and Child. Child is a field of Parent class.
Let's say we have two nodes. Node A and Node B. And both nodes are using a non-default both same portable version.

  • Child is serialized in Node B. This results with a class definition cached in Node B.
  • Parent is serialized in Node A and send to Node B.
  • When Node B is deserializing Parent, it reads the class definition of both Parent and Child from the wire.
  • In Node B, when reading the class definition of Child, the version of fields of Child class is read wrong.
  • We end up with the following exception when checking if the new class definition of Child is same as the cached one in Node B
Exception in thread "main" com.hazelcast.nio.serialization.HazelcastSerializationException: Incompatible class-definitions with same class-id: 
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=0}]} VS 
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=6}]}
	at com.hazelcast.internal.serialization.impl.PortableContextImpl$ClassDefinitionContext.register(PortableContextImpl.java:281)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.registerClassDefinition(PortableContextImpl.java:165)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:158)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:135)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.setupPositionAndDefinition(PortableSerializer.java:156)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.createReader(PortableSerializer.java:166)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:90)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:81)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:34)
	at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
	at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:191)

@sancar sancar added this to the 3.9.4 milestone Mar 28, 2018
@sancar sancar self-assigned this Mar 28, 2018
@sancar sancar removed the Type: Critical label Mar 28, 2018
sancar added a commit to sancar/hazelcast that referenced this issue Mar 28, 2018
…ted portables used

Portable serialization is mistakenly reporting incompatible class-definitions when nested portables are used in certain scenarios.
Details of failed scenario are as follows:
Let's say, we have two Portables: `Parent` and `Child`. `Child` is a field of `Parent` class.
Let's say we have two nodes. Node A and Node B. And both nodes are using a non-default both same portable version.
- `Child` is serialized in Node B. This results with a class definition cached in Node B.
- `Parent` is serialized in Node A and send to Node B.
- When Node B is deserializing `Parent`, it reads the class definition of both `Parent` and `Child` from the wire.
- In Node B, when reading the class definition of `Child`, the version of fields of `Child` class is read wrong.
- We end up with the following exception when checking if the new class definition of `Child` is same as the cached one in Node B
```
Exception in thread "main" com.hazelcast.nio.serialization.HazelcastSerializationException: Incompatible class-definitions with same class-id:
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=0}]} VS
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=6}]}
	at com.hazelcast.internal.serialization.impl.PortableContextImpl$ClassDefinitionContext.register(PortableContextImpl.java:281)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.registerClassDefinition(PortableContextImpl.java:165)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:158)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:135)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.setupPositionAndDefinition(PortableSerializer.java:156)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.createReader(PortableSerializer.java:166)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:90)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:81)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:34)
	at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
	at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:191)

```

This pr contains both fix and some cleanups.
Fix is to use class version in fields when reading class definition from wire.
In a couple places, fields are made private/final where applicable.

fixes hazelcast#12733
sancar added a commit to sancar/hazelcast that referenced this issue Mar 28, 2018
…ted portables used

Portable serialization is mistakenly reporting incompatible class-definitions when nested portables are used in certain scenarios.
Details of failed scenario are as follows:
Let's say, we have two Portables: `Parent` and `Child`. `Child` is a field of `Parent` class.
Let's say we have two nodes. Node A and Node B. And both nodes are using a non-default both same portable version.
- `Child` is serialized in Node B. This results with a class definition cached in Node B.
- `Parent` is serialized in Node A and send to Node B.
- When Node B is deserializing `Parent`, it reads the class definition of both `Parent` and `Child` from the wire.
- In Node B, when reading the class definition of `Child`, the version of fields of `Child` class is read wrong.
- We end up with the following exception when checking if the new class definition of `Child` is same as the cached one in Node B
```
Exception in thread "main" com.hazelcast.nio.serialization.HazelcastSerializationException: Incompatible class-definitions with same class-id:
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=0}]} VS
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=6}]}
	at com.hazelcast.internal.serialization.impl.PortableContextImpl$ClassDefinitionContext.register(PortableContextImpl.java:281)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.registerClassDefinition(PortableContextImpl.java:165)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:158)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:135)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.setupPositionAndDefinition(PortableSerializer.java:156)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.createReader(PortableSerializer.java:166)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:90)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:81)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:34)
	at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
	at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:191)

```

This pr contains both fix and some cleanups.
Fix is to use class version in fields when reading class definition from wire.
In a couple places, fields are made private/final where applicable.

fixes hazelcast#12733
sancar added a commit to sancar/hazelcast that referenced this issue Mar 30, 2018
…ted portables used

Portable serialization is mistakenly reporting incompatible class-definitions when nested portables are used in certain scenarios.
Details of failed scenario are as follows:
Let's say, we have two Portables: `Parent` and `Child`. `Child` is a field of `Parent` class.
Let's say we have two nodes. Node A and Node B. And both nodes are using a non-default both same portable version.
- `Child` is serialized in Node B. This results with a class definition cached in Node B.
- `Parent` is serialized in Node A and send to Node B.
- When Node B is deserializing `Parent`, it reads the class definition of both `Parent` and `Child` from the wire.
- In Node B, when reading the class definition of `Child`, the version of fields of `Child` class is read wrong.
- We end up with the following exception when checking if the new class definition of `Child` is same as the cached one in Node B
```
Exception in thread "main" com.hazelcast.nio.serialization.HazelcastSerializationException: Incompatible class-definitions with same class-id:
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=0}]} VS
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=6}]}
	at com.hazelcast.internal.serialization.impl.PortableContextImpl$ClassDefinitionContext.register(PortableContextImpl.java:281)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.registerClassDefinition(PortableContextImpl.java:165)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:158)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:135)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.setupPositionAndDefinition(PortableSerializer.java:156)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.createReader(PortableSerializer.java:166)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:90)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:81)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:34)
	at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
	at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:191)

```

This pr contains both fix and some cleanups.
Fix is to use class version in fields when reading class definition from wire.
In a couple places, fields are made private/final where applicable.

fixes hazelcast#12733
sancar added a commit to sancar/hazelcast that referenced this issue Mar 30, 2018
…ted portables used

Portable serialization is mistakenly reporting incompatible class-definitions when nested portables are used in certain scenarios.
Details of failed scenario are as follows:
Let's say, we have two Portables: `Parent` and `Child`. `Child` is a field of `Parent` class.
Let's say we have two nodes. Node A and Node B. And both nodes are using a non-default both same portable version.
- `Child` is serialized in Node B. This results with a class definition cached in Node B.
- `Parent` is serialized in Node A and send to Node B.
- When Node B is deserializing `Parent`, it reads the class definition of both `Parent` and `Child` from the wire.
- In Node B, when reading the class definition of `Child`, the version of fields of `Child` class is read wrong.
- We end up with the following exception when checking if the new class definition of `Child` is same as the cached one in Node B
```
Exception in thread "main" com.hazelcast.nio.serialization.HazelcastSerializationException: Incompatible class-definitions with same class-id:
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=0}]} VS
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=6}]}
	at com.hazelcast.internal.serialization.impl.PortableContextImpl$ClassDefinitionContext.register(PortableContextImpl.java:281)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.registerClassDefinition(PortableContextImpl.java:165)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:158)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:135)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.setupPositionAndDefinition(PortableSerializer.java:156)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.createReader(PortableSerializer.java:166)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:90)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:81)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:34)
	at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
	at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:191)

```

This pr contains both fix and some cleanups.
Fix is to use class version in fields when reading class definition from wire.
In a couple places, fields are made private/final where applicable.

fixes hazelcast#12733
sancar added a commit to sancar/hazelcast that referenced this issue Mar 30, 2018
…ted portables used

Portable serialization is mistakenly reporting incompatible class-definitions when nested portables are used in certain scenarios.
Details of failed scenario are as follows:
Let's say, we have two Portables: `Parent` and `Child`. `Child` is a field of `Parent` class.
Let's say we have two nodes. Node A and Node B. And both nodes are using a non-default both same portable version.
- `Child` is serialized in Node B. This results with a class definition cached in Node B.
- `Parent` is serialized in Node A and send to Node B.
- When Node B is deserializing `Parent`, it reads the class definition of both `Parent` and `Child` from the wire.
- In Node B, when reading the class definition of `Child`, the version of fields of `Child` class is read wrong.
- We end up with the following exception when checking if the new class definition of `Child` is same as the cached one in Node B
```
Exception in thread "main" com.hazelcast.nio.serialization.HazelcastSerializationException: Incompatible class-definitions with same class-id:
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=0}]} VS
ClassDefinition{factoryId=1, classId=2, version=6, fieldDefinitions=[FieldDefinitionImpl{index=0, fieldName='name', type=UTF, classId=0, factoryId=0, version=6}]}
	at com.hazelcast.internal.serialization.impl.PortableContextImpl$ClassDefinitionContext.register(PortableContextImpl.java:281)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.registerClassDefinition(PortableContextImpl.java:165)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:158)
	at com.hazelcast.internal.serialization.impl.PortableContextImpl.readClassDefinition(PortableContextImpl.java:135)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.setupPositionAndDefinition(PortableSerializer.java:156)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.createReader(PortableSerializer.java:166)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:90)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:81)
	at com.hazelcast.internal.serialization.impl.PortableSerializer.read(PortableSerializer.java:34)
	at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
	at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:191)

```

This pr contains both fix and some cleanups.
Fix is to use class version in fields when reading class definition from wire.
In a couple places, fields are made private/final where applicable.

fixes hazelcast#12733
@sancar sancar closed this in #12734 Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.