--- old/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java 2016-08-31 15:28:32.026864294 +0530 +++ new/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java 2016-08-31 15:28:31.794864294 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, 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 @@ -1328,14 +1328,15 @@ } // Finally, we are ready to read - - processImageStarted(currentImage); - boolean aborted = false; - - // Note that getData disables acceleration on buffer, but it is - // just a 1-line intermediate data transfer buffer that will not - // affect the acceleration of the resulting image. + /* + * All the Jpeg processing happens in native, we should clear + * abortFlag of imageIODataStruct in imageioJPEG.c. And we need + * clear abortFlag because without that consecutive read calls + * will become invalid. + */ + clearNativeReadAbortFlag(structPointer); + processImageStarted(currentImage); aborted = readImage(structPointer, buffer.getData(), numRasterBands, @@ -1513,6 +1514,12 @@ int maxProgressivePass, boolean wantUpdates); + /* + * We should call clearNativeReadAbortFlag() before we start reading + * jpeg image as image processing happens at native side. + */ + private native void clearNativeReadAbortFlag(long structPointer); + public void abort() { setThreadLock(); try {