RFR: 8316388: Opensource five Swing component related regression tests [v3]

Alexey Ivanov aivanov at openjdk.org
Thu Mar 14 09:34:40 UTC 2024


On Wed, 13 Mar 2024 20:49:19 GMT, Alexander Zuev <kizune at openjdk.org> wrote:

>> test/jdk/javax/swing/JEditorPane/bug4694598.java line 64:
>> 
>>> 62:         } catch (IOException ioe){
>>> 63:             throw new RuntimeException("Could not create html file to embed", ioe);
>>> 64:         }
>> 
>> Move creating the file to `main` method before setting up GUI and let `IOException` escape from main.
>
> This is try-with-resources so if i will do it in main i will have to add synchronizing and closing of writer which is a strange trade-off so i would have to do try block anyways.

Why would you need synchronisation?


        try (Writer writer = Files.newBufferedWriter(frameContentFile)) {
            writer.write(frameContentString);
        }

would write out the contents of the file and close the file handle. In setupGui, you would still use `frameContentFile` object only which is `final` and immutable, therefore it's thread-safe.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18259#discussion_r1524529046


More information about the client-libs-dev mailing list