Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class BinaryClassDescriptor {
initialSerializer = serializer;

// If serializer is not defined at this point, then we have to use OptimizedMarshaller.
useOptMarshaller = serializer == null || CommonUtils.isGeometryClass(cls);
useOptMarshaller = serializer == null || CommonUtils.isGeometryClass(cls) || cls.isRecord();

// Reset reflective serializer so that we rely on existing reflection-based serialization.
if (serializer instanceof BinaryReflectiveSerializer)
Expand Down Expand Up @@ -231,8 +231,8 @@ else if (useOptMarshaller)

if (useOptMarshaller && userType && !CommonUtils.isIgnite(cls) && !CommonUtils.isJdk(cls) && !CommonUtils.isGeometryClass(cls)) {
CommonUtils.warnDevOnly(ctx.log(), "Class \"" + cls.getName() + "\" cannot be serialized using " +
BinaryMarshaller.class.getSimpleName() + " because it either implements Externalizable interface " +
"or have writeObject/readObject methods. " + OptimizedMarshaller.class.getSimpleName() + " will be " +
BinaryMarshaller.class.getSimpleName() + " because it either implements Externalizable interface, " +
"have writeObject/readObject methods, or is a record. " + OptimizedMarshaller.class.getSimpleName() + " will be " +
"used instead and class instances will be deserialized on the server. Please ensure that all nodes " +
"have this class in classpath. To enable binary serialization either implement " +
Binarylizable.class.getSimpleName() + " interface or set explicit serializer using " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ public void testNull() throws Exception {
assertNull(marshalUnmarshal(null));
}

/**
* @throws Exception If failed.
*/
@Test
public void testRecord() throws Exception {
TestRecord testRecord = new TestRecord("value", 42L);

assertEquals(testRecord, marshalUnmarshal(testRecord));
}

/**
* @throws Exception If failed.
*/
Expand Down Expand Up @@ -6277,4 +6287,10 @@ public TwoCollections() {
v = new Value(127);
}
}

/** */
private record TestRecord(String value, long timestamp) implements Serializable {
// No-op.
}

}