RFR: 8328957: Update PKCS11Test.java to not use hardcoded path [v2]

Matthew Donovan mdonovan at openjdk.org
Tue Mar 26 17:51:21 UTC 2024


On Tue, 26 Mar 2024 16:31:06 GMT, Martin Balao <mbalao at openjdk.org> wrote:

> Hi @mpdonova ,
> 
> Thanks for contributing this fix. I've seen in java.nio.file.Files::find doc an implementation note saying that it should be used in a try-with-resource fashion to close the stream and any open directories. Should we consider this?
> 
> One more question. The ".orElse(path).getParent()" code path, what case is it intended for? I wonder in which cases this is expected to succeed.
> 
> Martin.-

I think adding the try-with-resources is a good idea. Always better to close things that potentially leave them open.

The `orElse(path).getParent()` was to return a default path that was then used higher-up on the call stack to check for the existence of the library. Looking at it again, that seemed redundant, since this change also looks for the existence of the library, so I refactored the code a little bit for the new `findNssLibrary()` method to return the path to the library or throw a SkippedException.

I think this is a cleaner way to do it.

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

PR Comment: https://git.openjdk.org/jdk/pull/18488#issuecomment-2021101482



More information about the security-dev mailing list