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

NPE exception throws in PrintServce.getSupportedAttributeValues

XMLWordPrintable

    • 2d
    • b132
    • x86
    • windows_xp
    • Not verified

      J2SE Version (please include all output from java -version flag):
      JDK 1.5.0_15

      Operating System Configuration Information (be specific):
      Win_xp


      Hardware Configuration Information (be specific):
      "Xerox DC 400/350/250 PCL 6" on windows XP,
      the driver Version: 3.0.6 (<PCL 6 printer driver > http://www.fxap.com.sg/download/suppdrv4.jsp?os=Windows+XP&productId=22)


      Bug Description:
      We have some NPE with a single printer driver "Xerox DC 400/350/250 PCL 6" on windows XP.
      After analyzing the code we think the line:

      printService.getSupportedAttributeValues( Media.class,??, ??);

      produce the exception.

      After reviewing the source code of Win32PrintService
      we think that the exception occur because the variable "mediaSizeNames" is null
      and the variable " trays " is not null.

      This seems to be a problem in the driver but it should not result in a NPE.
      Because this occur inside of the PrinterJob we have no change for a workaround.

      The execptions are:

      java.lang.NullPointerException

      at sun.print.Win32PrintService.getSupportedAttributeValues(Unknown Source)
      at com.inet.viewer.print.f.a(Unknown Source)
      com.inet.viewer.ViewerException: java.lang.NullPointerException

      at com.inet.viewer.PrinterJobProgress.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)

      Caused by: java.lang.NullPointerException
      at sun.print.Win32PrintService.getSupportedAttributeValues(Unknown Source)
      at sun.print.RasterPrinterJob.updatePageAttributes(Unknown Source)
      at sun.print.RasterPrinterJob.setPrintable(Unknown Source)
      at sun.print.RasterPrinterJob.setAttributes(Unknown Source)
      at sun.awt.windows.WPrinterJob.setAttributes(Unknown Source)
      at sun.print.RasterPrinterJob.print(Unknown Source)
       ... 2 more

      But we have look in the source code from Java 5 and Java 6 and there is no difference.

              } else if (category == Media.class) {
                  initMedia();
                  int len = (mediaSizeNames == null) ? 0 : mediaSizeNames.length;
                  MediaTray[] trays = getMediaTrays();
                  len += (trays == null) ? 0 : trays.length;
                  Media []arr = new Media[len];
                  if (mediaSizeNames != null) {
                      System.arraycopy(mediaSizeNames, 0, arr,
                                       0, mediaSizeNames.length);
                  }
                  if (trays != null) {
                      System.arraycopy(trays, 0, arr,
                                       mediaSizeNames.length, trays.length); <-- NullPointerException if mediaSizeNames is null
                  }
                  return arr;

            jgodinez Jennifer Godinez (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: