# HG changeset patch # User jgodinez # Date 1227652716 28800 # Node ID 90d4fe987b09b0a0b4a52c496a411a6c61147093 # Parent f617a19a81a7ed867408ca428499a4d91628c5c3 6653384: Variable "initialized" in class CUPSPrinter is static by mistake Reviewed-by: tdv, prr diff -r f617a19a81a7 -r 90d4fe987b09 jdk/src/solaris/classes/sun/print/CUPSPrinter.java --- a/jdk/src/solaris/classes/sun/print/CUPSPrinter.java Tue Nov 18 18:32:31 2008 -0800 +++ b/jdk/src/solaris/classes/sun/print/CUPSPrinter.java Tue Nov 25 14:38:36 2008 -0800 @@ -46,9 +46,9 @@ public class CUPSPrinter { - + private static final String debugPrefix = "CUPSPrinter>> "; private static final double PRINTER_DPI = 72.0; - private static boolean initialized; + private boolean initialized; private static native String getCupsServer(); private static native int getCupsPort(); private static native boolean canConnect(String server, int port); @@ -156,7 +156,7 @@ /** * Initialize media by translating PPD info to PrintService attributes. */ - private void initMedia() { + private synchronized void initMedia() { if (initialized) { return; } else { @@ -392,9 +392,9 @@ * Detects if CUPS is running. */ public static boolean isCupsRunning() { - IPPPrintService.debug_println("libFound "+libFound); + IPPPrintService.debug_println(debugPrefix+"libFound "+libFound); if (libFound) { - IPPPrintService.debug_println("CUPS server "+getServer()+ + IPPPrintService.debug_println(debugPrefix+"CUPS server "+getServer()+ " port "+getPort()); return canConnect(getServer(), getPort()); } else { diff -r f617a19a81a7 -r 90d4fe987b09 jdk/src/solaris/classes/sun/print/IPPPrintService.java --- a/jdk/src/solaris/classes/sun/print/IPPPrintService.java Tue Nov 18 18:32:31 2008 -0800 +++ b/jdk/src/solaris/classes/sun/print/IPPPrintService.java Tue Nov 25 14:38:36 2008 -0800 @@ -62,14 +62,23 @@ public class IPPPrintService implements PrintService, SunPrinterJobService { - public static boolean debugPrint = false; - private static String debugPrefix = "IPPPrintService>> "; + public static final boolean debugPrint; + private static final String debugPrefix = "IPPPrintService>> "; protected static void debug_println(String str) { if (debugPrint) { System.out.println(str); } } + private static final String FORCE_PIPE_PROP = "sun.print.ippdebug"; + + static { + String debugStr = + (String)java.security.AccessController.doPrivileged( + new sun.security.action.GetPropertyAction(FORCE_PIPE_PROP)); + + debugPrint = "true".equalsIgnoreCase(debugStr); + } private String printer; private URI myURI; @@ -383,7 +392,7 @@ if ((urlConnection = getIPPConnection(myURL)) == null) { mediaSizeNames = new MediaSizeName[0]; mediaTrays = new MediaTray[0]; - debug_println("NULL urlConnection "); + debug_println(debugPrefix+"initAttributes, NULL urlConnection "); init = true; return; } @@ -408,7 +417,7 @@ return; } catch (Exception e) { IPPPrintService.debug_println(debugPrefix+ - " error creating CUPSPrinter e="+e); + "initAttributes, error creating CUPSPrinter e="+e); } } @@ -912,6 +921,9 @@ * Finds matching CustomMediaSizeName of given media. */ public CustomMediaSizeName findCustomMedia(MediaSizeName media) { + if (customMediaSizeNames == null) { + return null; + } for (int i=0; i< customMediaSizeNames.length; i++) { CustomMediaSizeName custom = (CustomMediaSizeName)customMediaSizeNames[i]; @@ -1193,7 +1205,7 @@ return true; } for (int i=0; i= GRPTAG_OP_ATTRIBUTES) && (response[0] <= GRPTAG_PRINTER_ATTRIBUTES) && (response[0] != GRPTAG_END_ATTRIBUTES)) { - debug_println(debugPrefix+"checking group tag, response[0]= "+ + debug_println(debugPrefix+"readIPPResponse, checking group tag, response[0]= "+ response[0]); outObj = new ByteArrayOutputStream(); @@ -1773,6 +1786,7 @@ outArray); responseMap.put(ac.getName(), ac); + debug_println(debugPrefix+ "readIPPResponse "+ac); } outObj = new ByteArrayOutputStream(); @@ -1845,6 +1859,9 @@ } catch (java.io.IOException e) { debug_println(debugPrefix+"readIPPResponse: "+e); + if (debugPrint) { + e.printStackTrace(); + } return null; } } diff -r f617a19a81a7 -r 90d4fe987b09 jdk/test/java/awt/print/PrinterJob/GetMediasTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/print/PrinterJob/GetMediasTest.java Tue Nov 25 14:38:36 2008 -0800 @@ -0,0 +1,46 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6653384 + * @summary No exception should be thrown. + * @run main GetMediasTest + */ +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.attribute.standard.Media; + +public class GetMediasTest { + public static void main(String[] args) { + PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); + for(final PrintService service: services) { + Thread thread = new Thread() { + public void run() { + service.getSupportedAttributeValues(Media.class, null, null); + } + }; + thread.start(); + } + } +}