--- old/src/java.desktop/share/classes/javax/imageio/ImageIO.java 2016-03-15 23:45:16.305549000 +0530 +++ new/src/java.desktop/share/classes/javax/imageio/ImageIO.java 2016-03-15 23:45:15.701247000 +0530 @@ -1352,6 +1352,11 @@ } ImageInputStream stream = createImageInputStream(input); + + if (stream == null) { + throw new IIOException("Can't create an ImageInputStream!"); + } + BufferedImage bi = read(stream); if (bi == null) { stream.close(); @@ -1398,6 +1403,11 @@ throw new IIOException("Can't get input stream from URL!", e); } ImageInputStream stream = createImageInputStream(istream); + + if (stream == null) { + throw new IIOException("Can't create an ImageInputStream!"); + } + BufferedImage bi; try { bi = read(stream); @@ -1535,6 +1545,10 @@ throw new IIOException("Can't create output stream!", e); } + if (stream == null) { + throw new IIOException("Can't create an ImageOutputStream!"); + } + try { return doWrite(im, writer, stream); } finally { @@ -1577,6 +1591,10 @@ throw new IIOException("Can't create output stream!", e); } + if (stream == null) { + throw new IIOException("Can't create an ImageOutputStream!"); + } + try { return doWrite(im, getWriter(im, formatName), stream); } finally {