Skip to content

Commit bfe64a2

Browse files
committed
Addressed review comments. Spotless
1 parent 324e85e commit bfe64a2

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

pbj-core/pbj-runtime/src/main/java/com/hedera/pbj/runtime/hashing/WritableMessageDigest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,16 @@ public byte[] digest() {
5555
* {@link MessageDigest#getDigestLength()}, and {@link #position()} is reset to {@code 0},
5656
* matching the behavior of {@link #digest()}.
5757
*
58+
* Note: it's a responsibility of the caller to ensure that {@code buf} is large enough to hold the digest and
59+
* that offset is within bounds.
60+
*
5861
* @param buf the destination buffer for the digest bytes
5962
* @param offset the offset in {@code buf} where digest bytes are written
6063
* @throws RuntimeException if writing the digest into the destination buffer fails
64+
* @throws IllegalArgumentException if {@code offset} is out of bounds of {@code buf}
65+
* @throws RuntimeException if the digest operation fails, for example if the output buffer is too small to hold the digest
66+
* @see MessageDigest#digest(byte[], int, int)
67+
*
6168
*/
6269
public void digestInto(final byte[] buf, final int offset) {
6370
position = 0;

pbj-core/pbj-runtime/src/test/java/com/hedera/pbj/runtime/hashing/WritableMessageDigestTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ void testDigestInto(byte[] array) {
174174
assertEquals(0, wmd.position());
175175
assertArrayEquals(expectedDigest, Arrays.copyOfRange(output, 2, 2 + expectedDigest.length));
176176
assertArrayEquals(new byte[] {(byte) 0x55, (byte) 0x55}, Arrays.copyOfRange(output, 0, 2));
177-
assertArrayEquals(new byte[] {(byte) 0x55, (byte) 0x55}, Arrays.copyOfRange(output, 2 + expectedDigest.length, output.length));
177+
assertArrayEquals(
178+
new byte[] {(byte) 0x55, (byte) 0x55},
179+
Arrays.copyOfRange(output, 2 + expectedDigest.length, output.length));
178180
}
179181
}

0 commit comments

Comments
 (0)