[OpenJDK 2D-Dev] FileCacheImageOutputStream.close() is not idempotent
Martin Desruisseaux
martin.desruisseaux at geomatys.fr
Thu Jun 14 20:25:29 UTC 2012
Le 14/06/12 19:37, Phil Race a écrit :
> I think it acceptable to make it call checkClosed() conpatibility wise
> since apps must already be ready
> for an IOException and are actually less like to be ready for the NPE ..
After a second look to the code, it appears to have been the original
intend. All ImageInputStream and ImageOutputStream implementations
invoke super.close(), which in turn invoke checkClosed(). It just
appears that FileCacheImageOutputStream is making this invocation too
late - we get a NPE before to reach (indirectly) the checkClosed() call.
I attached to this email the new proposed fix.
Martin
-------------- next part --------------
diff -r b3246687c369 src/share/classes/javax/imageio/stream/FileCacheImageOutputStream.java
--- a/src/share/classes/javax/imageio/stream/FileCacheImageOutputStream.java Wed Jun 13 16:57:34 2012 -0700
+++ b/src/share/classes/javax/imageio/stream/FileCacheImageOutputStream.java Thu Jun 14 22:22:15 2012 +0200
@@ -222,11 +222,11 @@
* @exception IOException if an error occurs.
*/
public void close() throws IOException {
+ super.close(); // Must be invoked before dereferencing 'cache'.
maxStreamPos = cache.length();
seek(maxStreamPos);
flushBefore(maxStreamPos);
- super.close();
cache.close();
cache = null;
cacheFile.delete();
More information about the 2d-dev
mailing list