Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4929305

REG: Print Dialog freezes when selected print service does not support Doc Flvr

XMLWordPrintable

      I am calling ServiceUI.printDialog() to popup a print dialog. To this method, I have passed the default print service and a stream print service. The DocFlavor is INPUT_STREAM.POSTSCRIPT. This doc flavor is supported by the default print service but not by StreamPrintService. Initial PrintService is null. When I called the above method, no exception was thrown and a cross-platform dialog popped up. But when I tried to select the StreamPrintService an IllegalArgumentException was thrown saying this doc flavor is not supported. Once this exception was thrown, the application hangs and I am unable to click anything on the print dialog. Neither am I able to cancel the dialog. I have to exit from the application by pressing 'CTRL+C'.

      Though this exception is undocumented, this validation is still done at the time of popping up the print dialog but it is done only for the initial print service. If initial print service does not support the specified doc flavor, the dialog itself does not come up and this exception was thrown upfront. It would be better if this validation is done for all the services that are passed to the above method. Because once the dialog is popped up, there is no way the user can get out of the dialog if this exception is thrown. This is reproducible on all the platforms and on all the builds right from JDK1.4+.

      There is a difference between tiger and previous releases. In prev releases such as 1.4.2, 14.1, 1.4 the exception is thrown but the user can continue to work on the dialog or cancel it or he can select some other print service. But on Tiger, the dialog hangs once this exception is thrown.

      I have attached a sample testcase. Execute the sample testcase. You will get a cross-platform dialog. Select StreamPrintService from the drop-down and you will get the following exception.

      java.lang.IllegalArgumentException: application/postscript; class="java.io.InputStream" is an unsupported flavor
       at sun.print.PSStreamPrintService.getSupportedAttributeValues(PSStreamPrintService.java:237)
       at sun.print.ServiceDialog$MediaPanel.updateInfo(ServiceDialog.java:1824)
       at sun.print.ServiceDialog$PageSetupPanel.updateInfo(ServiceDialog.java:1171)
       at sun.print.ServiceDialog.updatePanels(ServiceDialog.java:373)
       at sun.print.ServiceDialog.access$1400(ServiceDialog.java:62)
       at sun.print.ServiceDialog$PrintServicePanel.popupMenuWillBecomeInvisible(ServiceDialog.java:721)
       at javax.swing.JComboBox.firePopupMenuWillBecomeInvisible(JComboBox.java:949)
       at javax.swing.plaf.basic.BasicComboPopup.firePopupMenuWillBecomeInvisible(BasicComboPopup.java:332)
       at javax.swing.JPopupMenu.setVisible(JPopupMenu.java:811)
       at javax.swing.JPopupMenu.menuSelectionChanged(JPopupMenu.java:1406)
       at javax.swing.MenuSelectionManager.setSelectedPath(MenuSelectionManager.java:77)
       at javax.swing.MenuSelectionManager.clearSelectedPath(MenuSelectionManager.java:109)
       at javax.swing.plaf.basic.BasicComboPopup.hide(BasicComboPopup.java:200)
       at javax.swing.plaf.basic.BasicComboBoxUI.setPopupVisible(BasicComboBoxUI.java:825)
       at javax.swing.JComboBox.setPopupVisible(JComboBox.java:786)
       at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:805)
       at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:232)
       at java.awt.Component.processMouseEvent(Component.java:5427)
       at javax.swing.JComponent.processMouseEvent(JComponent.java:2956)
       at javax.swing.plaf.basic.BasicComboPopup$2.processMouseEvent(BasicComboPopup.java:473)
       at java.awt.Component.processEvent(Component.java:5224)
       at java.awt.Container.processEvent(Container.java:1951)
       at java.awt.Component.dispatchEventImpl(Component.java:3922)
       at java.awt.Container.dispatchEventImpl(Container.java:2009)
       at java.awt.Component.dispatchEvent(Component.java:3770)
       at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4011)
       at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3726)
       at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3656)
       at java.awt.Container.dispatchEventImpl(Container.java:1995)
       at java.awt.Window.dispatchEventImpl(Window.java:1746)
       at java.awt.Component.dispatchEvent(Component.java:3770)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
       at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:214)
       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
       at java.awt.Dialog$1.run(Dialog.java:528)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:201)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
       at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:214)
       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
       at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

      I tested this on Win XP and Solaris8, 9.
      -----------------------------------------------------------------------------
      Since Print Dialog does not freeze in previous releases, this is a rergression in tiger. Changed the synopsis accordingly.

      ###@###.### 2003-09-29

            Unassigned Unassigned
            pmohansunw Praveen Mohan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: