Skip to content

JavaBinarySerializer.writeExternal writes a property count that doesn't match the bytes written #4328

Closed

Description

@ruispereira

Affected version: 26.4.2 (confirmed still present in 26.5.1)
Component: com.arcadedb.serializer.JavaBinarySerializer

Summary

The writer increments properties.size() as the property count at the start, then skips writing the size/payload bytes for properties where propValue == null or where the type cannot be inferred (type == -1). The reader iterates propertyCount times and reads UTF + int + bytes for each — so a single skipped property desyncs every subsequent read.

Code

engine/com/arcadedb/serializer/JavaBinarySerializer.java:57–86, 123–129

out.writeInt(properties.size());                        // count includes every entry
for (Map.Entry<String, Object> prop : properties.entrySet()) {
  out.writeUTF(propName);                               // always written
  if (propValue != null) {
    …
    if (type == -1) { log.warn(…); continue; }          // size/payload NOT written
    out.writeInt(buffer.size());
    out.write(buffer.getContent(), 0, buffer.size());
  }
  // null values: size/payload NOT written either
}

// readExternal:
final int propertyCount = in.readInt();
for (int i = 0; i < propertyCount; i++) {
  final String propName = in.readUTF();
  final int propertySize = in.readInt();
  final byte[] array = new byte[propertySize];
  in.read(array);                                       // see issue #10
  …
}

Impact

Any document with a null-valued or un-serializable property deserializes into garbage (wrong property names mapped to wrong bytes) or throws somewhere downstream with an opaque message.

Suggested fix

Filter the map down to serializable, non-null properties; write the filtered count and only filtered entries.

Activity

  1. self-assigned this
    on May 25, 2026
  2. added this to the 26.6.1 milestone on May 26, 2026
  3. added theissue type on May 26, 2026
  4. added 2 commits that reference this issue on May 27, 2026
  5. added a commit that references this issue on Jun 28, 2026
  6. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions