-
Bug
-
Resolution: Not an Issue
-
P3
-
6u10
-
x86
-
windows_vista
FULL PRODUCT VERSION :
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.0.6001]
A DESCRIPTION OF THE PROBLEM :
Shutdown hooks do not run to completion when the user logs out on Windows Vista.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the code below
2. Run it using "javaw ShutdownHookBug", a window should appear
3. Log out
4. Log back in
5. The file "shutdownhookbug.log" created in the user's home directory should contain "Hello " instead of "Hello world!"
Note that the log file contains the proper contents when the window is closed, as the shutdown hook runs to completion.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The file should contain "Hello world!"
ACTUAL -
The file contains "Hello "
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.io.File;
import java.io.FileOutputStream;
/**
* @author Jean-Francois Im
*/
public class ShutdownHookBug {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
// Write "Hello " to a file
File myFile = new File(System.getProperty("user.home") + File.separator + "shutdownhookbug.log");
FileOutputStream outputStream = new FileOutputStream(myFile);
outputStream.write("Hello ".getBytes());
outputStream.flush();
// Sleep for 5s
sleep(5000);
// Write "world!" and close the file
outputStream.write("world!".getBytes());
outputStream.flush();
outputStream.close();
} catch(Exception e) {
// Shouldn't happen.
}
}
});
}
}
---------- END SOURCE ----------
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.0.6001]
A DESCRIPTION OF THE PROBLEM :
Shutdown hooks do not run to completion when the user logs out on Windows Vista.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the code below
2. Run it using "javaw ShutdownHookBug", a window should appear
3. Log out
4. Log back in
5. The file "shutdownhookbug.log" created in the user's home directory should contain "Hello " instead of "Hello world!"
Note that the log file contains the proper contents when the window is closed, as the shutdown hook runs to completion.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The file should contain "Hello world!"
ACTUAL -
The file contains "Hello "
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.io.File;
import java.io.FileOutputStream;
/**
* @author Jean-Francois Im
*/
public class ShutdownHookBug {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
// Write "Hello " to a file
File myFile = new File(System.getProperty("user.home") + File.separator + "shutdownhookbug.log");
FileOutputStream outputStream = new FileOutputStream(myFile);
outputStream.write("Hello ".getBytes());
outputStream.flush();
// Sleep for 5s
sleep(5000);
// Write "world!" and close the file
outputStream.write("world!".getBytes());
outputStream.flush();
outputStream.close();
} catch(Exception e) {
// Shouldn't happen.
}
}
});
}
}
---------- END SOURCE ----------