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

getSupportedAttributeValues fails when called from multiple threads

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • client-libs
    • 2d
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.6.0-rc"
      Java(TM) SE Runtime Environment (build 1.6.0-rc-b104)
      Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-rc-b104, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux kowhai 2.6.16.28-xen-dom0 #4 SMP Mon Sep 25 18:45:18 BST 2006 x86_64 Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      At least two print services must be installed to reproduce this bug

      A DESCRIPTION OF THE PROBLEM :
      PrintService.getSupportedAttributeValues throws a NullPointerException when called from multiple threads.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the given code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
        To run without throwing any exceptions, and to print the media count for each print service installed on that machine.
      ACTUAL -
      A NullPointerException was thrown.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "Thread-2" java.lang.NullPointerException
              at sun.print.IPPPrintService.getSupportedAttributeValues(IPPPrintService
      .java:515)
              at GetMediasTest$1.run(GetMediasTest.java:11)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.print.PrintService;
      import javax.print.PrintServiceLookup;
      import javax.print.attribute.standard.Media;

      public class GetMediasTest {
          public static void main(String[] args) {
              PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
              for(final PrintService service: services) {
                  Thread thread = new Thread() {
                      public void run() {
                          service.getSupportedAttributeValues(Media.class, null, null);
                      }
                  };
                  thread.start();
              }
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Replace the contents of the run method with:

      synchronized (GetMediasTest.class) {
          service.getSupportedAttributeValues(Media.class, null, null);
      }

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: