Skip to content

Commit

Permalink
IGNITE-22736 Fix log buffers position change by unmarshalling process (
Browse files Browse the repository at this point in the history
  • Loading branch information
ibessonov authored Jul 15, 2024
1 parent a0811f9 commit 8f510c4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ protected void beforeWriteMessage(Object o, ByteBuffer buffer) {

@Override
public <T> T unmarshall(ByteBuffer raw) {
raw = raw.duplicate();

int requiredCatalogVersion = readRequiredCatalogVersion(raw);

T res = super.unmarshall(raw);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ protected void beforeWriteMessage(Object o, ByteBuffer buffer) {

@Override
public <T> T unmarshall(ByteBuffer raw) {
raw = raw.duplicate();

int requiredCatalogVersion = readRequiredCatalogVersion(raw);

T res = super.unmarshall(raw);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ void deserializationWorks() {
NetworkMessage message = commandWithRequiredCatalogVersion(42);

byte[] serialized = partitionCommandsMarshaller.marshall(message);
ByteBuffer buffer = ByteBuffer.wrap(serialized);

FinishTxCommand unmarshalled = partitionCommandsMarshaller.unmarshall(serialized);
FinishTxCommand unmarshalled = partitionCommandsMarshaller.unmarshall(buffer);

assertThat(unmarshalled.requiredCatalogVersion(), is(42));
assertThat(buffer.position(), is(0));

assertThat(partitionCommandsMarshaller.readRequiredCatalogVersion(ByteBuffer.wrap(serialized)), is(42));
assertThat(partitionCommandsMarshaller.readRequiredCatalogVersion(buffer), is(42));
}
}

0 comments on commit 8f510c4

Please sign in to comment.