RFR: 8057558 VirtualMachineImpl.execute on windows should close PipedInputStream before throwing exceptions

Staffan Larsen staffan.larsen at oracle.com
Tue Sep 9 05:39:13 UTC 2014


On 8 sep 2014, at 22:03, serguei.spitsyn at oracle.com wrote:

> On 9/8/14 12:59 PM, Staffan Larsen wrote:
>> 
>> On 8 sep 2014, at 21:26, serguei.spitsyn at oracle.com wrote:
>> 
>>> This looks good to me.
>> 
>> Thanks.
>> 
>>> 
>>> A minor question:
>>> 
>>> src/jdk.attach/windows/classes/sun/tools/attach/VirtualMachineImpl.java
>>>  110                 is.close();
>>> 
>>> An IOException can be thrown in the readErrorMessage().
>>> Would it make sense to use a finally statement to close the stream?
>> In most cases the stream is returned from the method so we can’t always close it.
> 
> In this particular case the stream is not returned from the method call:
>  103             PipedInputStream is = new PipedInputStream(hPipe);

123             // return the input stream
124             return is;

/Staffan


> 
> Thanks,
> Serguei
> 
>> 
>> /Staffan
>> 
>> 
>>> 
>>> Thanks,
>>> Serguei
>>> 
>>> On 9/8/14 5:25 AM, Staffan Larsen wrote:
>>>> Two fixes:
>>>> - The PipedInputStream used by the attach code on windows is not closed in case of errors
>>>> - The InputStreams returned by VirtualMachine.execute are not closed by all callers
>>>> 
>>>> webrev: http://cr.openjdk.java.net/~sla/8057558/webrev.00/
>>>> bug: https://bugs.openjdk.java.net/browse/JDK-8057558
>>>> 
>>>> Thanks,
>>>> /Staffan
>>> 
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20140909/0147e1de/attachment.html>


More information about the serviceability-dev mailing list