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

javax.print.PrintServiceLookup allows to register null service

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.0, 9
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
    • Resolved In Build:
      b36

      Backports

        Description

        Consider the following code:

        ----------------------------------------------------------
        import javax.print.PrintServiceLookup;
        import java.util.Arrays;

        public class PS {

            public static void main(String[] args) {
                final boolean registered = PrintServiceLookup.registerService(null);
                System.out.println("registered? " + registered);
                System.out.println("services = " + Arrays.toString(PrintServiceLookup.lookupPrintServices(null, null)));
            }
        }
        ----------------------------------------------------------

        After running it v.s. JDK8 updates the output will contain

        ----
        registered? true
        ...
        ----

        and the list of services with null among them.

        This doesn't look like conforming to the spec of the methods:

        http://docs.oracle.com/javase/8/docs/api/javax/print/PrintServiceLookup.html#registerService-javax.print.PrintService-
        http://docs.oracle.com/javase/8/docs/api/javax/print/PrintServiceLookup.html#lookupPrintServices-javax.print.DocFlavor-javax.print.attribute.AttributeSet-

        The spec needs to be clarified or behavior corrected.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                prr Philip Race
                Reporter:
                dbessono Dmitry Bessonov
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: