7022228: JPRT failure: RuntimeException in SupportedMedia regression test
authorjgodinez
Thu, 24 Feb 2011 15:00:50 -0800
changeset 8408 e3dac3bc81d1
parent 8407 ce70b4ff6423
child 8409 028496a4fa68
7022228: JPRT failure: RuntimeException in SupportedMedia regression test Reviewed-by: igor, prr
jdk/src/windows/classes/sun/print/Win32PrintService.java
--- a/jdk/src/windows/classes/sun/print/Win32PrintService.java	Mon Feb 21 14:33:58 2011 -0800
+++ b/jdk/src/windows/classes/sun/print/Win32PrintService.java	Thu Feb 24 15:00:50 2011 -0800
@@ -273,6 +273,20 @@
                 return DMPAPER_B6_JIS;
             }
         }
+
+        // If not found in predefined Windows ID, then we search through
+        // the returned IDs of the driver because they can define their own
+        // unique IDs.
+        initMedia();
+
+        if ((idList != null) && (mediaSizes != null) &&
+            (idList.size() == mediaSizes.length)) {
+            for (int i=0; i< idList.size(); i++) {
+                if (mediaSizes[i].getMediaSizeName() == msn) {
+                    return ((Integer)idList.get(i)).intValue();
+                }
+            }
+        }
         return 0;
     }
 
@@ -439,7 +453,7 @@
 
             if (mediaName != null) {
                 int defPaper = findPaperID(mediaName);
-                float[] prnArea = getMediaPrintableArea(printer, defPaper);
+                float[] prnArea = (defPaper != 0) ? getMediaPrintableArea(printer, defPaper) : null;
                 MediaPrintableArea printableArea = null;
                 if (prnArea != null) {
                     try {