RFR: 6616245: NullPointerException when using JFileChooser with a custom FileView [v2]

Alexey Ivanov aivanov at openjdk.org
Mon Oct 3 11:49:24 UTC 2022


On Mon, 3 Oct 2022 11:32:17 GMT, Tejesh R <tr at openjdk.org> wrote:

>> test/jdk/javax/swing/JFileChooser/FileViewNPETest.java line 84:
>> 
>>> 82:         String path = "";
>>> 83:         if (Platform.isWindows()) {
>>> 84:             path = "C:" + File.separator + "temp";
>> 
>> It's rare but possible that Windows is installed not on `C:` drive.
>
> Since temp will be better option without creating any new directory for the test, I didn't change it (it was reused from JBS report). Any other alternative......?

Why not request the path to the system temporary directory?

Temporary directory on Windows is not located in `C:\temp`. Likely this folder does not exist. You should use `TMP` or `TEMP` environment variable. Alternatively, you can use `createTempFile` from from [`java.io.File`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/File.html#createTempFile(java.lang.String,java.lang.String)) or [`java.nio.Files`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Files.html#createTempFile(java.lang.String,java.lang.String,java.nio.file.attribute.FileAttribute...)) to create a file in the temp directory, its parent is the path to the temp directory.

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

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



More information about the client-libs-dev mailing list