On Tue, 1 Aug 2023 07:15:51 GMT, Prasanta Sadhukhan <[email protected]> 
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
>
> Prasanta Sadhukhan has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Use try-with-resource

Marked as reviewed by aivanov (Reviewer).

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java line 
2605:

> 2603:                     try (Reader r = importFlavor.getReaderForText(t)) {
> 2604: 
> 2605:                         if (modeBetween) {

Is this comment necessary? It's the purpose of 
[try-with-resources](https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html),
 “The try-with-resources statement ensures that each resource is closed at the 
end of the statement.”

I believe the blank line before the first statement in the body of the try 
block isn't necessary either.

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

PR Review: https://git.openjdk.org/jdk/pull/15033#pullrequestreview-1556630721
PR Review Comment: https://git.openjdk.org/jdk/pull/15033#discussion_r1280402168

Reply via email to