On Wed, 13 Mar 2024 20:49:19 GMT, Alexander Zuev <kiz...@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

Reply via email to