Skip to content

HDDS-15115. CrcUtil/CrcComposer should not throw IOException for non-IO.#10139

Merged
szetszwo merged 3 commits into
apache:masterfrom
szetszwo:HDDS-15115
Apr 27, 2026
Merged

HDDS-15115. CrcUtil/CrcComposer should not throw IOException for non-IO.#10139
szetszwo merged 3 commits into
apache:masterfrom
szetszwo:HDDS-15115

Conversation

@szetszwo
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Similar to HADOOP-19035, CrcUtil and CrcComposer should throw specific exceptions for non-IO cases

  • IllegalArgumentException: invalid arguments
  • ArrayIndexOutOfBoundsException: index exceeds array size
  • IllegalStateException: unexpected computation state

What is the link to the Apache JIRA

HDDS-15115

How was this patch tested?

Copied tests from Hadoop.

@Russole
Copy link
Copy Markdown
Contributor

Russole commented Apr 26, 2026

Thanks @szetszwo for working on this. The changes look good to me. I just left a few minor comments.

@szetszwo
Copy link
Copy Markdown
Contributor Author

... I just left a few minor comments.

@Russole , thanks for reviewing this! But it seems you have not yet posted your comments. Could you check?

// CRC corresponding to the actual cellSize boundary.
assertThrows(IllegalStateException.class,
() -> digester.update(crcsByChunk[1], CELL_SIZE),
"stripe");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: assertThrows third argument is the assertion failure message, not an assertion on the exception message. If needed, we can capture the exception and check ex.getMessage() explicitly.

Suggested change
"stripe");
IllegalStateException ex = assertThrows(IllegalStateException.class,
() -> digester.update(crcsByChunk[1], CELL_SIZE));
assertTrue(ex.getMessage().contains("stripe"));


assertThrows(IllegalArgumentException.class,
() -> digester.update(crcBytesByChunk, 0, 6, CHUNK_SIZE),
"length");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here, I think assertThrows third argument is only the assertion failure message, not a check on the thrown exception message.

Suggested change
"length");
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
() -> digester.update(crcBytesByChunk, 0, 6, CHUNK_SIZE));
assertTrue(ex.getMessage().contains("length"));

int polynomial = CrcUtil.getCrcPolynomialForType(type);
return new CrcComposer(
polynomial,
org.apache.hadoop.ozone.client.checksum.CrcUtil.getMonomial(bytesPerCrcHint, polynomial),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional nit, unrelated to this change: we could use CrcUtil.getMonomial(...) here for consistency with the previous line.

Suggested change
org.apache.hadoop.ozone.client.checksum.CrcUtil.getMonomial(bytesPerCrcHint, polynomial),
CrcUtil.getMonomial(bytesPerCrcHint, polynomial),

@Russole
Copy link
Copy Markdown
Contributor

Russole commented Apr 26, 2026

Sorry @szetszwo, I forgot to submit the review comments. Submitted now. Thanks for the reminder!

@szetszwo
Copy link
Copy Markdown
Contributor Author

@Russole , Good catch on the problems! Just have pushed a fix. Please take a look.

@Russole
Copy link
Copy Markdown
Contributor

Russole commented Apr 27, 2026

Thanks @szetszwo for the updates. The changes look good to me. LGTM!

@szetszwo szetszwo closed this Apr 27, 2026
@szetszwo szetszwo reopened this Apr 27, 2026
@szetszwo szetszwo merged commit 9fb9bbe into apache:master Apr 27, 2026
89 of 90 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.

2 participants