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

unexpected NPE in javax.crypto.Mac.getProvider()

XMLWordPrintable

    • b32
    • sparc
    • solaris_2.6
    • Verified

      Name: ktR10099 Date: 11/18/2003



      There is no wording in the spec, that javax.crypto.Mac.getProvider() can't
      return null. Current implementation throws NPE, while trying to retrieve
      null provider. Please find below example, demonstrating the bug:
      ----------------------------------------------------------------
      import javax.crypto.*;
      import java.security.*;

      public class test137 {
          public static void main(String[] args) {
              MyMac mm = new MyMac(null, null, null);
              System.out.println("Mac created");
              System.out.println("Provider : " + mm.getProvider());
              System.out.println("Finished");
          }
      }

      class MyMac extends Mac {
          public MyMac(MacSpi macSpi, Provider provider,String algorithm) {
              super(macSpi, provider, algorithm);
          }
      }
      ------------------------output of test137-------------------------
      java full version "1.5.0-beta-b28"
      Mac created
      Exception in thread "main" java.lang.NullPointerException
              at javax.crypto.Mac.a(DashoA6275)
              at javax.crypto.Mac.getProvider(DashoA6275)
              at test137.main(test137.java:8)
      ------------------------------------------------------------------
      ======================================================================

            valeriep Valerie Peng
            kvtsunw Kvt Kvt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: