jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java
changeset 41403 be56daafbeaa
parent 35667 ed476aba94de
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java	Wed Sep 28 03:40:45 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java	Thu Sep 29 10:57:34 2016 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -156,6 +156,10 @@
 
         clearAbortRequest();
         processImageStarted(0);
+        if (abortRequested()) {
+            processWriteAborted();
+            return;
+        }
         if (param == null)
             param = getDefaultWriteParam();
 
@@ -583,12 +587,8 @@
             stream.write(embedded_stream.toByteArray());
             embedded_stream = null;
 
-            if (abortRequested()) {
-                processWriteAborted();
-            } else {
-                processImageComplete();
-                stream.flushBefore(stream.getStreamPosition());
-            }
+            processImageComplete();
+            stream.flushBefore(stream.getStreamPosition());
 
             return;
         }
@@ -606,9 +606,6 @@
             destScanlineLength = destScanlineBytes / (DataBuffer.getDataTypeSize(dataType)>>3);
         }
         for (int i = 0; i < h; i++) {
-            if (abortRequested()) {
-                break;
-            }
 
             int row = minY + i;
 
@@ -724,6 +721,9 @@
             }
 
             processImageProgress(100.0f * (((float)i) / ((float)h)));
+            if (abortRequested()) {
+                break;
+            }
         }
 
         if (compressionType == BI_RLE4 ||