--- old/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java 2016-09-27 11:54:16.788375353 +0530 +++ new/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFImageWriter.java 2016-09-27 11:54:16.548375353 +0530 @@ -2437,6 +2437,10 @@ clearAbortRequest(); processImageStarted(0); + if (abortRequested()) { + processWriteAborted(); + return; + } // Optionally write the header. if (writeHeader) { @@ -2587,9 +2591,6 @@ nextSpace = pos + byteCount; } - pixelsDone += tileRect.width*tileRect.height; - processImageProgress(100.0F*pixelsDone/totalPixels); - // Fill in the offset and byte count for the file stream.mark(); stream.seek(stripOrTileOffsetsPosition); @@ -2600,14 +2601,16 @@ stream.writeInt(byteCount); stripOrTileByteCountsPosition += 4; stream.reset(); + + pixelsDone += tileRect.width*tileRect.height; + processImageProgress(100.0F*pixelsDone/totalPixels); + if (abortRequested()) { + processWriteAborted(); + return; + } } catch (IOException e) { throw new IIOException("I/O error writing TIFF file!", e); } - - if (abortRequested()) { - processWriteAborted(); - return; - } } }