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

getDefaultAttributeValue(Media.class) returns null in CUPS system

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 5.0
    • client-libs
    • 2d
    • b73
    • x86
    • linux

      The following program throws NPE in CUPS because the default media is null.

      Media is a common attribute and should not be returning null. If CUPS printer is misconfigured that it returns null, jdk should be able to recover and return an acceptable default value like letter or a4 depending on locale.
       
      -------------------------------------------
      public static void main(String theParams[])
        {
          PrintService thePS = PrintServiceLookup.lookupDefaultPrintService();
          MediaPrintableArea thePrintableArea = null;
          MediaSize theMediaSize = null;
          Media theMedia = null;
          String theMarginsString = null;
          float theTopMargin = 0;
          float theLeftMargin = 0;
          float theBottomMargin = 0;
          float theRightMargin = 0;
          int theUnits = MediaPrintableArea.INCH;
          
          thePrintableArea = (MediaPrintableArea)thePS.getDefaultAttributeValue(MediaPrintableArea.class);
          theMedia = (Media)thePS.getDefaultAttributeValue(Media.class);
          theMediaSize = MediaSize.getMediaSizeForName((MediaSizeName)theMedia);

          System.out.println("Print Service: " + thePS);
          System.out.println("Default Media: " + theMedia.getClass() + " [" + theMedia);
          System.out.println(" Default Size: " + theMediaSize.getClass() + " [" + theMediaSize.toString(theUnits, "in"));
          System.out.println(" Print Area: " + thePrintableArea.toString(theUnits, "in"));
      }

      Tested using seahund linux machine.

            jgodinez Jennifer Godinez (Inactive)
            jgodinez Jennifer Godinez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: