[Hard] HugeGryoModule.java: ` — `EdgeLabelKryoSerializer.read()` returns null, unimpleme
Source
- File:
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/io/HugeGryoModule.java - References: L151-L152
Now I have a comprehensive picture of the issue. Let me summarize what I found:
-
In
HugeGryoModule.java, there are four Kryo serializer inner classes for schema types:PropertyKeyKryoSerializerVertexLabelKryoSerializerEdgeLabelKryoSerializerIndexLabelKryoSerializer
-
Each of these has a
write()method that is fully implemented (usingGraphSONSchemaSerializerto convert the schema object to aMap<HugeKeys, Object>, then writing it viawriteEntry()), and aread()method that is a stub returningnullwith a// TODOcomment. -
The
readEntry()helper method exists inHugeGryoModulebut is marked@SuppressWarnings("unused")— it reads back theMap<HugeKeys, Object>from the Kryo stream, but is never called by any of theread()methods. -
GraphSONSchemaSerializeronly haswrite*methods — there are no correspondingread*methods in it. TheSchemaSerializerinterface (in the backend serializer package) does havereadEdgeLabel,readVertexLabel, etc., but those take aHugeGraphand aBackendEntry, not aMap<HugeKeys, Object>. -
The TODO affects all 4 schema serializer
read()methods in the same file.
The issue is that Gryo (Kryo-based binary serialization used by TinkerPop) can serialize schema objects out but cannot deserialize them back. Any code path that tries to read a Gryo-serialized EdgeLabel, VertexLabel, PropertyKey, or IndexLabel from a binary stream will silently get null instead of the actual object.
The scope of the fix is confined to HugeGryoModule.java (1 file), but may also require adding read methods to GraphSONSchemaSerializer (1 file), for a total of 1-2 files affected.
The Issue
The TODO affects all four schema Kryo serializer inner classes in HugeGryoModule.java, not just EdgeLabelKryoSerializer. Each has a fully-implemented write() but a stub read() that unconditionally returns null:
PropertyKeyKryoSerializer.read() → // TODO, return null (line 151-154)
VertexLabelKryoSerializer.read() → // TODO, return null (line 165-168)
EdgeLabelKryoSerializer.read() → // TODO, return null (line 179-182)
IndexLabelKryoSerializer.read() → // TODO, return null (line 193-196)
What exactly is broken
The write() side works: it calls GraphSONSchemaSerializer.writeEdgeLabel() to produce a Map<HugeKeys, Object>, then serializes it to the Kryo binary stream via writeEntry().
The inverse path — readEntry() — already exists and correctly reads back the Map<HugeKeys, Object> from the stream, but it is annotated @SuppressWarnings("unused") because nothing calls it:
The missing piece is: after calling readEntry() to get the map back, there is no code to reconstruct an EdgeLabel (or any other schema object) from that map. GraphSONSchemaSerializer only has write* methods — it has no read* counterparts:
The backend SchemaSerializer interface does define readEdgeLabel(HugeGraph, BackendEntry) etc., but those operate on BackendEntry objects (storage-layer format), not on the Map<HugeKeys, Object> that the Gryo path produces:
Consequence
Any Gryo (TinkerPop binary) deserialization of schema objects — e.g. reading an EdgeLabel back from a Gryo stream — silently returns null. This would cause NPEs or incorrect behavior in any code path that round-trips schema objects through Gryo I/O (e.g. Gremlin result serialization over the binary protocol, graph export/import via Gryo).
What code needs to change
1 primary file needs changes:
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/io/HugeGryoModule.java— The fourread()stubs must be implemented. Each should callreadEntry()to recover theMap<HugeKeys, Object>, then reconstruct the schema object from that map.
1 supporting file likely also needs changes:
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/io/GraphSONSchemaSerializer.java— NeedsreadEdgeLabel(Map<HugeKeys,Object>, HugeGraph),readVertexLabel(...),readPropertyKey(...), andreadIndexLabel(...)methods added, mirroring the existingwrite*methods in reverse. (TheHugeGryoModuleserializers need aHugeGraphreference to reconstruct schema objects, which is a complication — the KryoSerializerAPI does not pass one in, so the serializer classes would need to hold a graph reference injected at registration time.)
Total: 2 files directly affected, with the core logic gap being the missing read* methods in GraphSONSchemaSerializer and the unimplemented read() bodies in HugeGryoModule.
This was created accidentally during testing ....closing. Sorry for the noise.