src/solaris/classes/sun/print/UnixPrintServiceLookup.java

Print this page

        

@@ -271,13 +271,29 @@
     public synchronized void refreshServices() {
         /* excludes the default printer */
         String[] printers = null; // array of printer names
         String[] printerURIs = null; //array of printer URIs
 
+        try {
         getDefaultPrintService();
+        } catch (Throwable t) {
+            IPPPrintService.debug_println(debugPrefix+
+              "Exception getting default printer : " + t);
+        }
         if (CUPSPrinter.isCupsRunning()) {
+            try {
             printerURIs = CUPSPrinter.getAllPrinters();
+                IPPPrintService.debug_println("CUPS URIs = " + printerURIs);
+                if (printerURIs != null) {
+                    for (int p = 0; p < printerURIs.length; p++) {
+                       IPPPrintService.debug_println("URI="+printerURIs[p]);
+                    }
+                }
+            } catch (Throwable t) {
+            IPPPrintService.debug_println(debugPrefix+
+              "Exception getting all CUPS printers : " + t);
+            }
             if ((printerURIs != null) && (printerURIs.length > 0)) {
                 printers = new String[printerURIs.length];
                 for (int i=0; i<printerURIs.length; i++) {
                     int lastIndex = printerURIs[i].lastIndexOf("/");
                     printers[i] = printerURIs[i].substring(lastIndex+1);

@@ -630,12 +646,14 @@
 
         IPPPrintService.debug_println("isRunning ? "+
                                       (CUPSPrinter.isCupsRunning()));
         if (CUPSPrinter.isCupsRunning()) {
             String[] printerInfo = CUPSPrinter.getDefaultPrinter();
+            if (printerInfo != null && printerInfo.length >= 2) {
             defaultPrinter = printerInfo[0];
             psuri = printerInfo[1];
+            }
         } else {
             if (isMac() || isSysV()) {
                 defaultPrinter = getDefaultPrinterNameSysV();
             } else if (isAIX()) {
                 defaultPrinter = getDefaultPrinterNameAIX();