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

Tejesh R tr at openjdk.org
Mon Oct 3 11:31:49 UTC 2022


On Mon, 3 Oct 2022 11:02:32 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Updated based on review comments
>
> src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java line 1271:
> 
>> 1269:             File curDir = getFileChooser().getCurrentDirectory();
>> 1270: 
>> 1271:             if (curDir != null && !curDir.equals(f)) {
> 
> If `f` is always not null, you can you use `!f.equals(curDir)`.

> 

Prevention of not setting to null means I have to modify `JFileChooser` class itself, so just handling here. And yeah` f `can't be null, can do that.

> test/jdk/javax/swing/JFileChooser/FileViewNPETest.java line 114:
> 
>> 112:         } else {
>> 113:             return false;
>> 114:         }
> 
> I can be simplified to:
> Suggestion:
> 
>         return ((filePath != null) && (filePath.isDirectory())
>                 && filePath.getAbsolutePath().startsWith(basePath));
> 
> I'm not insisting though.

Can be done, no issues.

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

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



More information about the client-libs-dev mailing list