RFR: 8288882: JFileChooser - empty (0 bytes) file is displayed as 1 KB [v14]

Abhishek Kumar duke at openjdk.org
Mon Aug 8 05:13:14 UTC 2022


On Fri, 5 Aug 2022 18:58:36 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Abhishek Kumar has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   creating and deleting test files dynamically
>
> test/jdk/javax/swing/JFileChooser/FileSizeCheck.java line 91:
> 
>> 89:         } catch (IOException ex) {
>> 90:             throw new RuntimeException(ex);
>> 91:         }
> 
> Probably, errors during test clean-up are not as important to fail the test?

> There are many comments. Could you, @kumarabhi006, summarise the approach taken, please?

@aivanov-jdk It has been observed that the particular code segment was executing only in linux OS. So, I am converting the received file length value(long)  to a double value with one decimal point to make it similar to native OS. The conversion factor taken here is 1000 in stead of 1024, same as the native file system. The converted double value is compared with basefilesize(1000.0) and formatted as per the file size units (KB, MB, GB) using MessageFormat.

Now, the file size shown in JFileChooser is similar to native file system in linux. Only the files having size 0-999 bytes is shown as either "0 KB" or "1 KB" as we are not handling "bytes" separately.

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

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



More information about the client-libs-dev mailing list