RFR: 6587699: Document DigestInputStream behavior when skip() or mark() / reset() is used

Bradford Wetmore wetmore at openjdk.org
Thu Jul 28 01:11:18 UTC 2022


On Wed, 27 Jul 2022 23:02:03 GMT, Weijun Wang <weijun at openjdk.org> wrote:

> Add an `@implNote` to clarify the behavior when these methods are called. A new test is added.

I'll approve this after CSR is approved.

src/java.base/share/classes/java/security/DigestInputStream.java line 54:

> 52:  * digest to be computed, leaving the original digest untouched.
> 53:  *
> 54:  * @implNote This implementation updates and only updates the message digest

The "updates and only updates" feel awkward.  Maybe just the one mention of update?

src/java.base/share/classes/java/security/DigestInputStream.java line 55:

> 53:  *
> 54:  * @implNote This implementation updates and only updates the message digest
> 55:  *      with data actually read from the input stream when it is turned on.

"when it is turned on"?  You could probably just end with "actually read from the input stream."

src/java.base/share/classes/java/security/DigestInputStream.java line 56:

> 54:  * @implNote This implementation updates and only updates the message digest
> 55:  *      with data actually read from the input stream when it is turned on.
> 56:  *      This includes various {@code read} methods, {@code transferTo},

includes the various

src/java.base/share/classes/java/security/DigestInputStream.java line 57:

> 55:  *      with data actually read from the input stream when it is turned on.
> 56:  *      This includes various {@code read} methods, {@code transferTo},
> 57:  *      {@code readAllBytes}, and {@code readNBytes}. Specifically, data

Specifically
->
Additionally ?

test/jdk/java/security/DigestInputStream/TestSkipAndReset.java line 62:

> 60: 
> 61:         byte[] hash = md.digest();
> 62:         byte[] directHash = md.digest("1267967889090".getBytes(StandardCharsets.UTF_8));

Very clear test, thank you.

-------------

PR: https://git.openjdk.org/jdk/pull/9667



More information about the security-dev mailing list