Login  Register

Data loss - window closable while save in progress

Posted by Michael Doube on Jun 25, 2009; 7:38am
URL: http://imagej.273.s1.nabble.com/Data-loss-window-closable-while-save-in-progress-tp3692008.html

Hi all,

I've struck a rather nasty (dangerous!) bug where it is possible to close an image while a save is in progress, resulting in loss of all image data.

For example, I have a 1GB stack and I hit [s] to save it.  While the write is in progress I hit [w] to close the window.  The window closes, IJ throws an exception and all the stack's data is gone.  The expected behaviour is for IJ to wait until it is finished saving, then to close the image.

The exception is this:

java.lang.NullPointerException
        at java.io.FileOutputStream.writeBytes(Native Method)
        at java.io.FileOutputStream.write(Unknown Source)
        at java.io.BufferedOutputStream.write(Unknown Source)
        at java.io.DataOutputStream.write(Unknown Source)
        at ij.io.ImageWriter.write8BitImage(ImageWriter.java:28)
        at ij.io.ImageWriter.write8BitStack(ImageWriter.java:38)
        at ij.io.ImageWriter.write(ImageWriter.java:214)
        at ij.io.TiffEncoder.write(TiffEncoder.java:118)
        at ij.io.TiffEncoder.write(TiffEncoder.java:138)
        at ij.io.FileSaver.saveAsTiffStack(FileSaver.java:126)
        at ij.io.FileSaver.saveAsTiff(FileSaver.java:80)
        at ij.io.FileSaver.save(FileSaver.java:58)
        at ij.plugin.Commands.save(Commands.java:55)
        at ij.plugin.Commands.run(Commands.java:27)
        at ij.IJ.runPlugIn(IJ.java:148)
        at ij.Executer.runCommand(Executer.java:121)
        at ij.Executer.run(Executer.java:58)
        at java.lang.Thread.run(Unknown Source)

I am using IJ 1.43b and Java 64-bit 1.6.0_12 on Vista.

I hope this message prevents other people from losing their work.

Mike