diff -r 7d593a130994 -r 1ccef37a150f jdk/src/share/classes/javax/imageio/stream/FileCacheImageOutputStream.java --- a/jdk/src/share/classes/javax/imageio/stream/FileCacheImageOutputStream.java Fri May 08 15:38:21 2009 +0400 +++ b/jdk/src/share/classes/javax/imageio/stream/FileCacheImageOutputStream.java Fri May 08 15:57:33 2009 +0400 @@ -48,6 +48,10 @@ // Pos after last (rightmost) byte written private long maxStreamPos = 0L; + /** The CloseAction that closes the stream in + * the StreamCloser's shutdown hook */ + private final StreamCloser.CloseAction closeAction; + /** * Constructs a FileCacheImageOutputStream that will write * to a given outputStream. @@ -82,7 +86,9 @@ this.cacheFile = File.createTempFile("imageio", ".tmp", cacheDir); this.cache = new RandomAccessFile(cacheFile, "rw"); - StreamCloser.addToQueue(this); + + this.closeAction = StreamCloser.createCloseAction(this); + StreamCloser.addToQueue(closeAction); } public int read() throws IOException { @@ -227,7 +233,7 @@ cacheFile = null; stream.flush(); stream = null; - StreamCloser.removeFromQueue(this); + StreamCloser.removeFromQueue(closeAction); } public void flushBefore(long pos) throws IOException {