--- old/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java 2016-09-27 11:54:16.188375353 +0530 +++ new/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java 2016-09-27 11:54:15.972375353 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2005, 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 @@ -1234,43 +1234,46 @@ clearAbortRequest(); processImageStarted(0); + if (abortRequested()) { + processWriteAborted(); + } else { + try { + write_magic(); + write_IHDR(); + + write_cHRM(); + write_gAMA(); + write_iCCP(); + write_sBIT(); + write_sRGB(); + + write_PLTE(); + + write_hIST(); + write_tRNS(); + write_bKGD(); + + write_pHYs(); + write_sPLT(); + write_tIME(); + write_tEXt(); + write_iTXt(); + write_zTXt(); - try { - write_magic(); - write_IHDR(); - - write_cHRM(); - write_gAMA(); - write_iCCP(); - write_sBIT(); - write_sRGB(); - - write_PLTE(); - - write_hIST(); - write_tRNS(); - write_bKGD(); - - write_pHYs(); - write_sPLT(); - write_tIME(); - write_tEXt(); - write_iTXt(); - write_zTXt(); - - writeUnknownChunks(); + writeUnknownChunks(); - write_IDAT(im, deflaterLevel); + write_IDAT(im, deflaterLevel); - if (abortRequested()) { - processWriteAborted(); - } else { - // Finish up and inform the listeners we are done - writeIEND(); - processImageComplete(); + if (abortRequested()) { + processWriteAborted(); + } else { + // Finish up and inform the listeners we are done + writeIEND(); + processImageComplete(); + } + } catch (IOException e) { + throw new IIOException("I/O error writing PNG file!", e); } - } catch (IOException e) { - throw new IIOException("I/O error writing PNG file!", e); } } }