[OpenJDK 2D-Dev] Review Request for JDK-8044289 : In ImageIO.read() and write() NPE is not handled properly for stream

Jayathirth D V jayathirth.d.v at oracle.com
Thu Mar 17 11:39:18 UTC 2016


Hi Phil,

 

Thanks for the review.

 

I have made following changes :

1) I am using File.createTempFile() both in case of read and write as a result of which we don't need external .png file which was there in previous                     webrev.

 

2) Also since I am using temporary file for read(url), I observed one more bug where I am not able to delete temporary file referenced by URL. This is     

happening because we are using the input url with openStream() API in ImageIO.read() and when createImageInputStream() returns null we are not closing the stream. So I have added additional code to close this stream so that temporary file can be deleted.

 

3) Corrected some typo's in test case comments.

 

Please find updated webrev for review :

http://cr.openjdk.java.net/~jdv/8044289/webrev.01/

 

Thanks,

Jay

From: Philip Race 
Sent: Wednesday, March 16, 2016 10:59 PM
To: Jayathirth D V
Cc: 2d-dev at openjdk.java.net
Subject: Re: Review Request for JDK-8044289 : In ImageIO.read() and write() NPE is not handled properly for stream

 

The test writes out into "test.src".
I believe that you should treat that as a "read-only" location.
Write to a tempfile (File.createTempFile()) or TESTCLASSES.

-phil.

On 3/15/16, 10:50 PM, Jayathirth D V wrote: 

Hi Phil,All

 

Please review the following fix in JDK9:

 

Bug : https://bugs.openjdk.java.net/browse/JDK-8044289 

 

Webrev : HYPERLINK "http://cr.openjdk.java.net/%7Ejdv/8044289/webrev.00/"http://cr.openjdk.java.net/~jdv/8044289/webrev.00/ 

 

Issue : When createImageInputStream() or createImageOutputStream returns null in ImageIO.read() or ImageIO.write() we are seeing NPE as it stream is used further without null check.

 

Root cause : "stream" is used without checking whether it is null or not.

 

Solution : Handle null pointer of stream and throw IIOException.

 

Test case contains all possible scenarios where createImageInputStream() or createImageOutputStream can return null.

 

Thanks,

Jay

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20160317/289e6fba/attachment.html>


More information about the 2d-dev mailing list