Skip to content

Conversation

@chesnokoff
Copy link
Contributor

Thank you for submitting the pull request to the Apache Ignite.

In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:

The Contribution Checklist

  • There is a single JIRA ticket related to the pull request.
  • The web-link to the pull request is attached to the JIRA ticket.
  • The JIRA ticket has the Patch Available state.
  • The pull request body describes changes that have been made.
    The description explains WHAT and WHY was made instead of HOW.
  • The pull request title is treated as the final commit message.
    The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
  • A reviewer has been mentioned through the JIRA comments
    (see the Maintainers list)
  • The pull request has been checked by the Teamcity Bot and
    the green visa attached to the JIRA ticket (see TC.Bot: Check PR)

Notes

If you need any help, please email [email protected] or ask anу advice on http://asf.slack.com #ignite channel.

@chesnokoff chesnokoff force-pushed the ignite-26646 branch 2 times, most recently from 42034b2 to 3f54423 Compare November 27, 2025 11:11
@chesnokoff chesnokoff force-pushed the ignite-26646 branch 3 times, most recently from c0db299 to 2aac42e Compare January 14, 2026 22:14
…niteIoCommunicationMessageSerializationTest#testMessageSerializationAndDeserializationConsistency
Comment on lines 68 to 69
if (data == null)
return new byte[0];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IgniteIoCommunicationMessageSerializationTest#testMessageSerializationAndDeserializationConsistency fails without null check

Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the fact that data is initialized in the constructor and cannot be null, I suggest removing this check and adding to IgniteIoCommunicationMessageSerializationTest#initializeMessage:

        if (msg instanceof PartitionUpdateCountersMessage)
            FieldUtils.writeField(msg, "data", new byte[0], true);

*/
public void payload(byte[] payload) {
data = payload;
size = data == null ? 0 : data.length / ITEM_SIZE;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IgniteCachePutGetRestartAbstractTest#testTxPutGetRestart fails without null check

Copy link
Contributor

Choose a reason for hiding this comment

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

MessageReader#readByteArray returns null when it couldn't fully extract the entire payload from the buffer because the complete byte array didn't fit into the read buffer.

Previously, we were setting the size after successfully reading the whole byte array using the reader.

In my opinion, the current logic seems fine.

/** */
private byte data[];
@Order(0)
private int cacheId;
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional change - usually we set Order according to the declaration order of fields in the class.
I would revert it, but it's up to you.

Copy link
Contributor Author

@chesnokoff chesnokoff Jan 19, 2026

Choose a reason for hiding this comment

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

I changed the field declaration order because writeTo/readFrom wrote the cacheId first and the data afterward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@chesnokoff , I agree with @wernerdv . It is not necessary to refactor order of fieds.

…ssageSerializationAndDeserializationConsistency
/** */
private byte data[];
@Order(0)
private int cacheId;
Copy link
Contributor

Choose a reason for hiding this comment

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

@chesnokoff , I agree with @wernerdv . It is not necessary to refactor order of fieds.

* @return Payload.
*/
public byte[] payload() {
return Arrays.copyOf(data, size * ITEM_SIZE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Possbile NPE here.
Also, we should ensure that it could not lead to a potential performance drop.

Copy link
Contributor

Choose a reason for hiding this comment

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

@chesnokoff , see an example:

Suggested change
return Arrays.copyOf(data, size * ITEM_SIZE);
return F.isEmpty(data) ? null : Arrays.copyOf(data, size * ITEM_SIZE);

if (msg instanceof NodeIdMessage)
FieldUtils.writeField(msg, "nodeId", UUID.randomUUID(), true);

if (msg instanceof PartitionUpdateCountersMessage)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this change? NPE should be properly fixed in a message.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggested removing the null check from the message and adding it to the test.
See #12402 (comment)
But the final decision is up to you.

Copy link
Contributor

@shishkovilja shishkovilja Jan 19, 2026

Choose a reason for hiding this comment

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

I suggested removing the null check from the message and adding it to the test. See #12402 (comment) But the final decision is up to you.

We can safely send null for empty or null array. BUT, as I see now, message will be in incorrect state if data is null.

So, you are right. Let's keep it.

/**
* @return Payload.
*/
public byte[] payload() {
Copy link
Contributor

Choose a reason for hiding this comment

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

May be just data?

Suggested change
public byte[] payload() {
public byte[] data() {


/** */
private int cacheId;
@Order(value = 1, method = "payload")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@Order(value = 1, method = "payload")
@Order(1)

(rename getter and setter to data)

@Order(0)
private int cacheId;

/** */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/** */
/** Byte representation of partition counters. */

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.

3 participants