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

Tejesh R tr at openjdk.org
Mon Oct 10 13:58:35 UTC 2022


On Mon, 10 Oct 2022 11:24:43 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Test case update
>
> test/jdk/javax/swing/JFileChooser/FileViewNPETest.java line 81:
> 
>> 79:         passFailJFrame = new PassFailJFrame("Test Instructions", INSTRUCTIONS, 5L, 13, 40);
>> 80:         jfc = new JFileChooser();
>> 81:         String path = System.getProperty("user.home");
> 
> The test does not work for me on Windows. It starts with `user.home` as the current folder as expected; when select `C:`, it goes to Desktop which is the root of the Shell namespace.
> 
> I guess, you have to change it to `System.getProperty("user.home") + File.separator + "Documents"` as you and I discussed. It'll make Desktop unreachable.
> 
> On Linux, the test works correctly.

Updated.

> test/jdk/javax/swing/JFileChooser/FileViewNPETest.java line 97:
> 
>> 95: 
>> 96: class CustomFileView extends FileView {
>> 97:     private String basePath;
> 
> Suggestion:
> 
>     private final String basePath;

Updated.

> test/jdk/javax/swing/JFileChooser/FileViewNPETest.java line 105:
> 
>> 103:     public Boolean isTraversable(File filePath) {
>> 104:         return ((filePath != null) && (filePath.isDirectory())) &&
>> 105:                 filePath.getAbsolutePath().startsWith(basePath);
> 
> Suggestion:
> 
>         return ((filePath != null) && (filePath.isDirectory()))
>                 && filePath.getAbsolutePath().startsWith(basePath);
> 
> I prefer wrapping before the operator, it makes it clear that it's a continuation line. Java Coding Style suggests wrapping this way.

Updated.

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

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



More information about the client-libs-dev mailing list