RFR: 8349151: Refactor test/java/security/cert/CertificateFactory/slowstream.sh to java test [v3]

Weijun Wang weijun at openjdk.org
Thu May 8 11:41:57 UTC 2025


On Thu, 8 May 2025 10:28:41 GMT, Mikhail Yankelevich <myankelevich at openjdk.org> wrote:

>> Refactor test/java/security/cert/CertificateFactory/slowstream.sh to java test
>
> Mikhail Yankelevich has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Rajan's comments

test/jdk/java/security/cert/CertificateFactory/SlowStream.java line 28:

> 26:  * @bug 6813340
> 27:  * @summary X509Factory should not depend on is.available()==0
> 28:  * @run main/othervm SlowStream

Why `othervm`?

test/jdk/java/security/cert/CertificateFactory/SlowStream.java line 53:

> 51:                             "pem"))) {
> 52: 
> 53:                         final byte[] buffer = new byte[4096];

This test was probably written very log ago where there was no NIO or `InputStream::readAllBytes`. The file itself is quite small and there is no need to read in blocks. You can use modern methods like `Files::readAllBytes` or `InputStream::transferTo`.

test/jdk/java/security/cert/CertificateFactory/SlowStream.java line 75:

> 73:             try {
> 74:                 final var factory = CertificateFactory.getInstance("X.509");
> 75:                 final var factorySize = factory.generateCertificates(inputStream).size();

Please change the variable name to something like `numOfCerts`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23394#discussion_r2079548084
PR Review Comment: https://git.openjdk.org/jdk/pull/23394#discussion_r2079545423
PR Review Comment: https://git.openjdk.org/jdk/pull/23394#discussion_r2079535807


More information about the security-dev mailing list