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

IIORegistry.getDefaultInstance() is not thread safe

XMLWordPrintable

                                      
      A DESCRIPTION OF THE PROBLEM :
      The method javax.imageio.spi.IIORegistry.getDefaultInstance() is not thread safe. If there are 2 threads that call this on start time there can be 2 instances of the default IIORegistry. If both thread register an ImageReaderSpi and/or ImageWriterSpi this can result in the sporadic lost of the registered objects:

      Suggested solution is to synchronized the creation:

              if (registry == null) {
      synchronized (context) {
      registry = (IIORegistry)context.get(IIORegistry.class);
      if (registry == null) {
                          // Create an instance for this AppContext
                          registry = new IIORegistry();
                          context.put(IIORegistry.class, registry);
      }
      }
              }




       

            jdv Jayathirth D V
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: