RFR: 4893524: Swing drop targets should call close() on transferred readers and streams
Alexey Ivanov
aivanov at openjdk.org
Mon Jul 31 09:55:53 UTC 2023
On Wed, 26 Jul 2023 07:15:56 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
> The issue here is a Reader(stream) is requested to handle a drop, via DataFlavor.getReaderForText(), and then the reader is completely read, but it isn't closed. It should be closed as soon as possible to release some native resources.
> Fix is made to close the stream after it is being used
Shall we also update the copyright year in `BasicTextUI`?
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java line 2613:
> 2611:
> 2612: handleReaderImport(r, c, useRead);
> 2613: r.close();
Should we use try-with-resources for Reader? This will ensure the stream is closed even if `handleReaderImport` throws an exception.
-------------
PR Review: https://git.openjdk.org/jdk/pull/15033#pullrequestreview-1554394185
PR Review Comment: https://git.openjdk.org/jdk/pull/15033#discussion_r1279064741
More information about the client-libs-dev
mailing list