-
Bug
-
Resolution: Not an Issue
-
P3
-
7u3, 8, 9
-
windows_7
FULL PRODUCT VERSION :
java version " 1.7.0_03 "
Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Try to remove a tray icon in system tray in a shutdown hook will prevent the vm terminate. The application will hang on the shutdown hook thread.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
You may need to prepare an png file 'icon.png' under D:Run code below and right click the system tray icon -> Exit.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The tray icon removed and java vm terminated
ACTUAL -
tray icon removed but vm will never exit
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.imageio.*;
public class NewClass {
public static void main(String... args) throws IOException, AWTException {
final TrayIcon yourTrayIcon = new TrayIcon(ImageIO.read(new File( " D:\\icon.png " )), " Icon " );
SystemTray.getSystemTray().add(yourTrayIcon);
final PopupMenu popup = new PopupMenu();
MenuItem exitItem = new MenuItem( " Exit " );
popup.add(exitItem);
exitItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
yourTrayIcon.setPopupMenu(popup);
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
if (SystemTray.isSupported()) {
SystemTray systemTray = SystemTray.getSystemTray();
systemTray.remove(yourTrayIcon);
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
remove the tray icon before call System.exit(0) don't have such problem/avoid remove trayicon in shutdown hook
java version " 1.7.0_03 "
Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Try to remove a tray icon in system tray in a shutdown hook will prevent the vm terminate. The application will hang on the shutdown hook thread.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
You may need to prepare an png file 'icon.png' under D:Run code below and right click the system tray icon -> Exit.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The tray icon removed and java vm terminated
ACTUAL -
tray icon removed but vm will never exit
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.imageio.*;
public class NewClass {
public static void main(String... args) throws IOException, AWTException {
final TrayIcon yourTrayIcon = new TrayIcon(ImageIO.read(new File( " D:\\icon.png " )), " Icon " );
SystemTray.getSystemTray().add(yourTrayIcon);
final PopupMenu popup = new PopupMenu();
MenuItem exitItem = new MenuItem( " Exit " );
popup.add(exitItem);
exitItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
yourTrayIcon.setPopupMenu(popup);
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
if (SystemTray.isSupported()) {
SystemTray systemTray = SystemTray.getSystemTray();
systemTray.remove(yourTrayIcon);
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
remove the tray icon before call System.exit(0) don't have such problem/avoid remove trayicon in shutdown hook