-
Notifications
You must be signed in to change notification settings - Fork 38
Closed
Description
Marshallers generated for classes with Map @ProtoField definitions always try to initialize the BaseMarshallerDelegate of the Map's value type to the _md$2 variable. Consequently, if there already exists a @ProtoField(2) definition for a type that also requires a BaseMarshallerDelegate, a ClassCastException will be thrown at runtime when the non-null _md$2 delegate is passed to a subsequent writeNestedMessage call.
Example definition:
@ProtoField(2)
BigInteger bigInteger;
@ProtoField(3)
Map<Integer, UUID> uuidMap;
@ProtoFactory
public MapOverlappingMarshallerDelegate(BigInteger bigInteger, Map<Integer, UUID> uuidMap) {
this.bigInteger = bigInteger;
this.uuidMap = uuidMap;
}Generated code:
@Override
public void write(org.infinispan.protostream.ProtobufTagMarshaller.WriteContext $1, org.infinispan.protostream.integrationtests.processor.marshaller.model.MapOverlappingMarshallerDelegate $2) throws java.io.IOException {
org.infinispan.protostream.impl.TagWriterImpl $out = (org.infinispan.protostream.impl.TagWriterImpl) $1.getWriter();
final org.infinispan.protostream.integrationtests.processor.marshaller.model.MapOverlappingMarshallerDelegate o = (org.infinispan.protostream.integrationtests.processor.marshaller.model.MapOverlappingMarshallerDelegate) $2;
{
final java.math.BigInteger __v$2 = (java.math.BigInteger) o.bigInteger;
if (__v$2 != null) {
if (__md$2 == null) __md$2 = ((org.infinispan.protostream.impl.SerializationContextImpl) $1.getSerializationContext()).getMarshallerDelegate(java.math.BigInteger.class);
writeNestedMessage(__md$2, $out, 2, __v$2);
}
}
{
final java.util.Map<java.lang.Integer, java.util.UUID> __c$3 = o.uuidMap;
if (__c$3 != null)
for (java.util.Iterator<java.util.Map.Entry<java.lang.Integer, java.util.UUID>> it = __c$3.entrySet().iterator(); it.hasNext(); ) {
final java.util.Map.Entry<java.lang.Integer, java.util.UUID> __v$3 = it.next();
try (NestedWriter $n = new NestedWriter($1, 3)) {
$out = $n.getWriter();
$out.writeInt32(1, __v$3.getKey().intValue());
{
if (__md$2 == null) __md$2 = ((org.infinispan.protostream.impl.SerializationContextImpl) $1.getSerializationContext()).getMarshallerDelegate(java.util.UUID.class);
writeNestedMessage(__md$2, $out, 2, __v$3.getValue());
}
}
$out = (org.infinispan.protostream.impl.TagWriterImpl) $1.getWriter();
}
}
}Exception:
java.lang.ClassCastException: class java.util.UUID cannot be cast to class java.math.BigInteger (java.util.UUID and java.math.BigInteger are in module java.base of loader 'bootstrap')
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels