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

UnixPrintJob doesn't handle mediaName vs customTray correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: P4 P4
    • 9
    • 7
    • client-libs
    • 2d
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.7.0_147-icedtea"
      OpenJDK Runtime Environment (IcedTea7 2.0) (7~b147-2.0-1)
      OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Debian Wheezy 3.0.0-2-amd64 #1 SMP Fri Oct 7 20:48:45 UTC 2011 x86_64 GNU/Linux

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      The system is linked with a network printer (Brother HL5350DNLT) that works correctly in cups.

      A DESCRIPTION OF THE PROBLEM :
      When printing to a tray (so setting the Tray-option in a printrequest) the printjob sends an invalid argument-list to lpr.

      I've done some testing and debuged the problem to a deep level and I noticed that in com.sun.UnixPrintJob the var mediaName is pre-assigned with a default value. If you check the code in the class, you'll see that this means that this var can never be null and that in the print-method this line will always be executed:
      mOptions = " media="+ customMedia.getChoiceName(); (line 349)

      If you've also selected a tray, then also the line mOptions += " media="+choice; (line 357) is executed.
      This means that mOptions matches something like "media=letter media=Tray2".

      I've checked the documentation (cups) and there is mentioned that
      only 1 of these 2 parameters can be there (or combined with a "," to media=letter,Tray2)
      For more info about these options: http://www.cups.org/documentation.php/options.html

      Note 1: the same could be true for the awt-printing infrastructure (e.g. PSPrintJob)
      Note 2: I've also noticed that other apps pass the tray as "InputSlot=Tray2" to cups but I didn't investigate this any further.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) take a similar printer - a network printer with multiple trays (if possible the same)
      2) create a small app that prints to tray 2
      3) run the app and validate the result

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      check that the printer took a sheet from tray 2 and printed the content
      ACTUAL -
      printer gives an error related to the media-parameters

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
                      //Assign the networkprinter
      PrintService p = Printers.getPrinterByName("HL5350DNLT");

                      //set tray 2 as output
                      MediaTray tray2 = ... //Select tray 2 from the supported attribute list
      PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
      attributes.add(tray2);

                      //Create a print job
      DocPrintJob job = p.createPrintJob();
      job.print(new SimpleDoc("Test", DocFlavor.STRING.TEXT_PLAIN, null), attributes);
      ---------- END SOURCE ----------

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: