|
Quick Lists
|
|
Bug ID:
|
4894964
|
|
Votes
|
0
|
|
Synopsis
|
If ImageOutputStream.close() is not explicitly called, temp file is not deleted
|
|
Category
|
java:imageio
|
|
Reported Against
|
1.4.2
|
|
Release Fixed
|
|
|
State
|
11-Closed, duplicate of 4171239,
bug
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
4171239
|
|
Submit Date
|
23-JUL-2003
|
|
Description
|
FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
FULL OPERATING SYSTEM VERSION :
customer Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
Using ImageIO.write() to write to an ImageOutputStream
results in a temporary file being created and never
deleted. The temp file is typically something like:
C:\Documents and Settings\<username>\Local
Settings\Temp\imageio8733.tmp
Explicitly calling ImageOutputStream.close() deletes the
temp file.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the attached sample program with an input image file
and an output image file name
2. Monitor your temp file directory and observe the new
imageioXXX.tmp file that remains after the program exits.
EXPECTED VERSUS ACTUAL BEHAVIOR :
The temp file should be cleaned up when the VM exits if
close() was not explicitly called.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.imageio.*;
import javax.imageio.stream.*;
import java.awt.image.*;
import java.io.*;
// ImageIO leaves a temp file around after exiting unless
ImageOutputStream.close() is called
// e.g. under W2K the file is something like C:\Documents and
Settings\<username>\Local Settings\Temp\imageio8733.tmp
public class ImageWriteCache {
public static void main(String args[]) throws Exception {
if (args.length != 2) {
System.err.println("Usage: ImageWriteCache
<inputimagefile> <outputimagefile>");
System.exit(1);
}
BufferedImage image = ImageIO.read(new File(args[0]));
if (image == null) {
System.err.println("Failed to load image " + args[0]);
System.exit(1);
}
ImageOutputStream ios = ImageIO.createImageOutputStream(new
FileOutputStream(args[1]));
if (ios == null || !ImageIO.write(image, "JPEG", ios)) {
System.err.println("Failed to write image " + args[1]);
System.exit(1);
}
// Uncomment this line and the temp file will be deleted
//ios.close();
}
}
---------- END SOURCE ----------
(Incident Review ID: 163578)
======================================================================
|
|
Work Around
|
N/A
|
|
Evaluation
|
The temporary file is created by the instance of
javax.imageio.steram.FileCacheImageOutputStream.
This file is marked as "deleted on exit" as soon as it is created.
If we do not close corresponding instance of
FileCacheImageOutputStream the the temporary file is not closed and so
it is not deleted on VM exit due to bug 4171239.
======================================================================
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |