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

PrintServiceLookup.lookupPrintServices() does not return consistent result

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 7u21
    • client-libs
    • None
    • 2d
    • b96

    Backports

      Description

        FULL PRODUCT VERSION :
        java version " 1.7.0_21 "
        Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
        Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Linux bisonws0043.infra.local 3.8.5-201.fc18.x86_64 #1 SMP Thu Mar 28 21:01:19 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

        A DESCRIPTION OF THE PROBLEM :
        PrintServiceLookup.lookupPrintServices() method does not return the same print service implementations if print services where searched by name as if they are not filtered.


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1) Install two printers: " TestOne " and " TestTwo "
        2) Lookup all print services without any filtering AttributeSet
        3) Compare the instance class with the one receivend on looking up all found print services by their name.


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The implementer class is always the same if filtered or not.
        ACTUAL -
        The implementer class for the returned PrintService implementation differs if the printer name is not the default.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import sun.print.UnixPrintServiceLookup;

        import javax.print.PrintService;
        import javax.print.PrintServiceLookup;
        import javax.print.attribute.AttributeSet;
        import javax.print.attribute.HashAttributeSet;
        import javax.print.attribute.standard.PrinterName;

        public class GetPrintServices {

          public static void main(String[] args) throws Exception {
            UnixPrintServiceLookup lookup = new UnixPrintServiceLookup();
            for (PrintService service : lookup.getPrintServices(null, null)) {
              PrintService serviceByName = lookupByName(lookup, service.getName());
              if (!service.getClass().equals(serviceByName.getClass())) {
                throw new RuntimeException( " NOK expected: " + service + " got: " + serviceByName);
              }
            }
            System.out.println( " Test PASSED " );
          }

          private static PrintService lookupByName(UnixPrintServiceLookup lookup, String name) {
            AttributeSet attributes = new HashAttributeSet();
            attributes.add(new PrinterName(name, null));
            for (PrintService service : lookup.getPrintServices(null, attributes)) {
              return service;
            }
            return null;
          }
        }

        ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved: