diff --git a/versioned/storage/common-serialize/src/main/java/org/projectnessie/versioned/storage/serialize/ProtoSerialization.java b/versioned/storage/common-serialize/src/main/java/org/projectnessie/versioned/storage/serialize/ProtoSerialization.java index aa9b7d1ee3b..467239887da 100644 --- a/versioned/storage/common-serialize/src/main/java/org/projectnessie/versioned/storage/serialize/ProtoSerialization.java +++ b/versioned/storage/common-serialize/src/main/java/org/projectnessie/versioned/storage/serialize/ProtoSerialization.java @@ -297,7 +297,10 @@ public static Obj deserializeObjProto(ObjId id, ObjProto obj, String versionToke return deserializeUniqueId(id, obj.getUniqueId()); } if (obj.hasCustom()) { - return deserializeCustom(id, obj.getCustom(), versionToken); + return deserializeCustom( + id, + obj.getCustom(), + versionToken != null ? versionToken : obj.getCustom().getVersionToken()); } throw new UnsupportedOperationException("Cannot deserialize " + obj); } @@ -506,9 +509,14 @@ private static UniqueIdProto.Builder serializeUniqueId(UniqueIdObj obj) { private static Obj deserializeCustom(ObjId id, CustomProto custom, String versionToken) { ObjType type = ObjTypes.forShortName(custom.getObjType()); + if (versionToken == null) { + // versionToken is set when reading objects from the database, but cache-deserialization has + // the versionToken in the object + versionToken = custom.getVersionToken(); + } return SmileSerialization.deserializeObj( id, - versionToken != null ? versionToken : custom.getVersionToken(), + versionToken, custom.getData().toByteArray(), type.targetClass(), custom.getCompression().name());