On Mon, 14 Aug 2023 20:25:08 GMT, Sergey Bylokhov <[email protected]> wrote:
>> Alexander Zvegintsev has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> fix app exit issue
>
> src/java.desktop/unix/classes/sun/awt/screencast/ScreencastHelper.java line
> 127:
>
>> 125: @Override
>> 126: public void run() {
>> 127: closeSession();
>
> What happen if the "closeSession" is executed why the new Robot#getRGBPixels
> is called? In the robot code we call timerCloseSessionRestart to
> restart/cancel timer, but I think it could be possible that closeSession() is
> already executed and may close session right before it will be used by the
> robot but after we "open" it.
>
> Or this case is not possible?
Both `ScreencastHelper#getRGBPixels`(`Robot#getRGBPixels` calls it internally)
and `ScreencastHelper#closeSession` are synchronized.
So `ScreencastHelper#closeSession` will wait until the execution of
`ScreencastHelper#getRGBPixels` is finished and vice versa.
Many hours of testing with random delays close to DELAY_BEFORE_SESSION_CLOSE
worked fine.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15250#discussion_r1294037138