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

spec: unsetOrdering of ServiceRegistry throws unspecified exception

XMLWordPrintable

    • beta2
    • generic
    • generic



      Name: ipR10067 Date: 06/09/2001


       
      The description for the method unsetOrdering of class javax.imageio.spi.ServiceRegistry
      says nothing about method's behaviour when parameters "firstProvider" and "secondProvider"
      are null or they are the same object.
      The specification looks like incomplete.

      Current implementation (build 1.4.0-beta_refresh-b67) throws NullPointerException
      when parameter firstProvider is null
      and do nothing when parameter secondProvider is null or
      parameters firstProvider and secondProvider are the same object.


      See the sample below for details:
      ========================== Tests.java =============================
      import java.util.Vector;
      import java.util.Locale;
      import javax.imageio.spi.ServiceRegistry;
      import javax.imageio.spi.ImageReaderSpi;
      import javax.imageio.ImageReader;
      import java.io.IOException;

      public class Tests {

          public static void main(String argv[]) {
              
              Vector inCategories = new Vector ();
              inCategories.add(ImageReaderSpi.class);
              ServiceRegistry serviceRegistry = new ServiceRegistry(inCategories.iterator());
              MyServiceProvider myServiceProvider = new MyServiceProvider();
             
              System.out.println ("----- both parameters are null ------");
              try {
                  serviceRegistry.unsetOrdering(ImageReaderSpi.class, null, null);
                  System.out.println ("No exception was thrown\n");
              } catch (Throwable iae) {
                  System.out.println ("Throws " + iae.toString() + "\n");
              }
         
              System.out.println ("----- parameter secondProvider is null ------");
              try {
                  serviceRegistry.unsetOrdering(ImageReaderSpi.class, myServiceProvider, null);
                  System.out.println ("No exception was thrown\n");
              } catch (Throwable iae) {
                  System.out.println ("Throws " + iae.toString() + "\n");
              }
          

              System.out.println ("----- parameter firstProvider is null ------");
              try {
                  serviceRegistry.unsetOrdering(ImageReaderSpi.class, null, myServiceProvider);
                  System.out.println ("No exception was thrown\n");
              } catch (Throwable iae) {
                  System.out.println ("Throws " + iae.toString() + "\n");
              }
       
              System.out.println ("----- parameters firstProvider and secondProvider are the same ------");
              try {
                  serviceRegistry.unsetOrdering(ImageReaderSpi.class, myServiceProvider, myServiceProvider);
                  System.out.println ("No exception was thrown\n");
              } catch (Throwable iae) {
                  System.out.println ("Throws " + iae.toString() + "\n");
              }
          
              return;
          }
      }


      class MyServiceProvider extends ImageReaderSpi {

         MyServiceProvider(){
             super();
         }

         MyServiceProvider(String vendorName, String version, String[] names,
             String[] suffixes, String[] MIMETypes, String readerClassName,
             Class[] inputTypes, String[] writerSpiNames,
             boolean supportsStandardStreamMetadataFormat,
             String nativeStreamMetadataFormatName,
             String nativeStreamMetadataFormatClassName,
             String[] extraStreamMetadataFormatNames,
             String[] extraStreamMetadataFormatClassNames,
             boolean supportsStandardImageMetadataFormat,
             String nativeImageMetadataFormatName,
             String nativeImageMetadataFormatClassName,
             String[] extraImageMetadataFormatNames,
             String[] extraImageMetadataFormatClassNames){

             super(vendorName, version, names, suffixes, MIMETypes,readerClassName,
                   inputTypes, writerSpiNames, supportsStandardStreamMetadataFormat,
                   nativeStreamMetadataFormatName,
                   nativeStreamMetadataFormatClassName,
                   extraStreamMetadataFormatNames,
                   extraStreamMetadataFormatClassNames,
                   supportsStandardImageMetadataFormat, nativeImageMetadataFormatName,
                   nativeImageMetadataFormatClassName, extraImageMetadataFormatNames,
                   extraImageMetadataFormatClassNames);
         }

         public boolean canDecodeInput(Object source){
             return true;
         }

         public ImageReader createReaderInstance (Object extension) throws IOException {
             return null;
         }

         public String getDescription(Locale locale) {
             return "MyServiceProvider";
         }
      }

      ==========================log========================
      >java -version
      java version "1.4.0-beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b67)
      Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b67, mixed mode)
      >java Tests
      ----- both parameters are null ------
      Throws java.lang.NullPointerException

      ----- parameter secondProvider is null ------
      No exception was thrown

      ----- parameter firstProvider is null ------
      Throws java.lang.NullPointerException

      ----- parameters firstProvider and secondProvider are the same ------
      No exception was thrown


      ======================================================================

            dricesunw Daniel Rice (Inactive)
            ipsunw Ip Ip (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: