--- a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java Tue Nov 17 19:15:48 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java Wed Nov 18 00:20:15 2015 +0300
@@ -778,8 +778,15 @@
// Check for native, note that default dialog is COMMON.
if (dlg == DialogTypeSelection.NATIVE) {
PrintService pservice = getPrintService();
- PageFormat page = pageDialog(attributeToPageFormat(pservice,
- attributes));
+ PageFormat pageFrmAttrib = attributeToPageFormat(pservice,
+ attributes);
+ PageFormat page = pageDialog(pageFrmAttrib);
+
+ // If user cancels the dialog, pageDialog() will return the original
+ // page object and as per spec, we should return null in that case.
+ if (page == pageFrmAttrib) {
+ return null;
+ }
updateAttributesWithPageFormat(pservice, page, attributes);
return page;
}