--- old/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java 2016-08-31 15:28:32.546864294 +0530 +++ new/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java 2016-08-31 15:28:32.330864294 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -937,12 +937,6 @@ for (int srcY = 0; srcY < passHeight; srcY++) { // Skip filter byte and the remaining row bytes pixelStream.skipBytes(1 + bytesPerRow); - - // If read has been aborted, just return - // processReadAborted will be called later - if (abortRequested()) { - return; - } } } @@ -996,6 +990,13 @@ for (int srcY = 0; srcY < passHeight; srcY++) { // Update count of pixels read updateImageProgress(passWidth); + /* + * If read has been aborted, just return + * processReadAborted will be called later + */ + if (abortRequested()) { + return; + } // Skip filter byte and the remaining row bytes pixelStream.skipBytes(1 + bytesPerRow); } @@ -1105,7 +1106,13 @@ for (int srcY = 0; srcY < passHeight; srcY++) { // Update count of pixels read updateImageProgress(passWidth); - + /* + * If read has been aborted, just return + * processReadAborted will be called later + */ + if (abortRequested()) { + return; + } // Read the filter type byte and a row of data int filter = pixelStream.read(); try { @@ -1195,12 +1202,6 @@ updateWidth, 1, updateXStep, updateYStep, destinationBands); - - // If read has been aborted, just return - // processReadAborted will be called later - if (abortRequested()) { - return; - } } } @@ -1215,8 +1216,6 @@ this.pixelsDone = 0; this.totalPixels = width*height; - clearAbortRequest(); - if (metadata.IHDR_interlaceMethod == 0) { decodePass(0, 0, 0, 1, 1, width, height); } else { @@ -1241,8 +1240,10 @@ (height + ybump)/YSubsampling); } - // If read has been aborted, just return - // processReadAborted will be called later + /* + * If read has been aborted, just return + * processReadAborted will be called later + */ if (abortRequested()) { return; } @@ -1332,13 +1333,19 @@ inputBandsForColorType[colorType], theImage.getSampleModel().getNumBands()); + clearAbortRequest(); processImageStarted(0); - decodeImage(); if (abortRequested()) { processReadAborted(); } else { - processImageComplete(); + decodeImage(); + if (abortRequested()) { + processReadAborted(); + } else { + processImageComplete(); + } } + } catch (IOException e) { throw new IIOException("Error reading PNG image data", e); } finally {