Skip to content

Conversation

@mzitnik
Copy link
Contributor

@mzitnik mzitnik commented Nov 9, 2025

Summary

Due to the incorrect implementation of the serialization state

Closes #52 #63

Checklist

Delete items not relevant to your PR:

@mzitnik mzitnik marked this pull request as ready for review November 11, 2025 09:46
Copy link

@windsurf-bot windsurf-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other comments (1)

💡 To request another review, post a new comment with "/windsurf-review".

serializer.serializeRequestToStream(clickHousePayload, dos);
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(baos.toByteArray()));

ClickHousePayload clickHousePayload1 = serializer.deserializeRequestFromStream(dos.size(), dis);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an issue with the size parameter in the deserialization call. DataOutputStream doesn't have a size() method, but ByteArrayOutputStream does. You should use baos.size() instead of dos.size().

Suggested change
ClickHousePayload clickHousePayload1 = serializer.deserializeRequestFromStream(dos.size(), dis);
ClickHousePayload clickHousePayload1 = serializer.deserializeRequestFromStream(baos.size(), dis);

serializer.serializeRequestToStream(clickHousePayload, dos);
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(baos.toByteArray()));

ClickHousePayload clickHousePayload1 = serializer.deserializeRequestFromStream(dos.size(), dis);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an issue with the deserialization step. DataOutputStream doesn't have a size() method. You should use baos.size() instead to get the correct byte count.

Suggested change
ClickHousePayload clickHousePayload1 = serializer.deserializeRequestFromStream(dos.size(), dis);
ClickHousePayload clickHousePayload1 = serializer.deserializeRequestFromStream(baos.size(), dis);

Comment on lines 38 to 48
protected ClickHousePayload deserializeRequestFromStream(long requestSize, DataInputStream dataInputStream) throws IOException {
if (requestSize > 0) {
int version = dataInputStream.readInt();
if (version == V1) {
return deserializeV1(dataInputStream);
} else {
throw new IOException("Unsupported version " + version);
}
} else {
throw new IOException("Unsupported version: " + version);
throw new IOException("Request size: " + requestSize);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a mismatch between serialization and deserialization logic. In serializeRequestToStream(), you write version first, then length. But in deserializeRequestFromStream(), you're checking requestSize before reading the version. This could cause issues deserializing data that was serialized with the previous implementation.

Consider ensuring the serialization and deserialization logic are symmetric to maintain backward compatibility.

@mshustov
Copy link
Member

Due to the incorrect implementation of the serialization state

@mzitnik do we need to review the area and expand the test coverage?

@mzitnik mzitnik requested a review from BentsiLeviav November 15, 2025 06:58
@mzitnik mzitnik merged commit 824184d into main Nov 16, 2025
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FlinkRuntimeException: Failed to deserialize value

4 participants