Munoon commented on issue #1481: URL: https://github.com/apache/incubator-fury/issues/1481#issuecomment-2043147929
> Why not make `MapSerializers.HashMapSerializer mapSerializer ` as an instance variable of your serializer The following refactoring: ```java public static class StorageSerializer extends Serializer<Storage> { private final MapSerializers.HashMapSerializer mapSerializer; public StorageSerializer(Fury fury) { super(fury, Storage.class); this.mapSerializer = new MapSerializers.HashMapSerializer(fury); this.mapSerializer.setKeySerializer(new KeySerializer(fury)); } @Override public void write(MemoryBuffer buffer, Storage value) { mapSerializer.write(buffer, value.map()); } @Override public Storage read(MemoryBuffer buffer) { HashMap<Key, String> map = mapSerializer.read(buffer); return new Storage(map); } } ``` Leads to the following exception: ``` Exception in thread "main" java.lang.IndexOutOfBoundsException: readerIndex(13) + length(2) exceeds size(14): MemoryBuffer{size=14, readerIndex=13, writerIndex=0, heapMemory=len(14), heapData=[-1, 1, -1, 1, 0, 0, 0, -1, 44, 0, 3, 97, 98, 99], heapOffset=0, offHeapBuffer=null, address=16, addressLimit=30} at io.fury.memory.MemoryBuffer.readShort(MemoryBuffer.java:2031) at io.fury.resolver.EnumStringResolver.trySkipEnumStringBytes(EnumStringResolver.java:140) at io.fury.resolver.EnumStringResolver.readEnumStringBytes(EnumStringResolver.java:110) at io.fury.resolver.ClassResolver.readClassInfoFromBytes(ClassResolver.java:1628) at io.fury.resolver.ClassResolver.readClassInfoFromBytes(ClassResolver.java:1606) at io.fury.resolver.ClassResolver.readClassInfo(ClassResolver.java:1585) at io.fury.Fury.readRef(Fury.java:814) at io.fury.serializer.collection.AbstractMapSerializer.generalJavaRead(AbstractMapSerializer.java:569) at io.fury.serializer.collection.AbstractMapSerializer.genericJavaRead(AbstractMapSerializer.java:444) at io.fury.serializer.collection.AbstractMapSerializer.readElements(AbstractMapSerializer.java:436) at io.fury.serializer.collection.MapSerializer.read(MapSerializer.java:47) at Test$StorageSerializer.read(Test.java:38) at Test$StorageSerializer.read(Test.java:22) at io.fury.Fury.readDataInternal(Fury.java:899) at io.fury.Fury.deserializeJavaObject(Fury.java:1060) at io.fury.Fury.deserializeJavaObject(Fury.java:1042) at Test.main(Test.java:18) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org For additional commands, e-mail: commits-h...@fury.apache.org