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

java.util.prefs.Preferences byte[] getByteArray(String key, byte[] def)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • core-libs
    • None
    • merlin
    • x86
    • windows_nt
    • Verified

      java.util.prefs.Preferences getByteArray(String key, byte[] def)

      NullPointerException not thrown when key =null

      Test program :
      -------------
       
      import java.util.prefs.*;
      import java.util.*;
       

      public class GetByteArrayTest {
          public static void main(String[] args) throws Exception {
         
            try {
                 Preferences userRoot = Preferences.userRoot();
                 Preferences N1 = userRoot.node("N1");
                 N1.clear();
                
                 byte [] value = new byte[1];
                 value[0]=(byte)2;
                 N1.putByteArray("k1",value);
                 byte[] valueExpected = value;
                 byte[] valuedefault = new byte[1];
                 valuedefault[0] = (byte)0;
                 byte[] valueGot = N1.getByteArray(null,valuedefault);
                 System.out.println("NullPointerException not thrown valueGot[0] = " + valueGot[0]);
            } catch(NullPointerException npe) {
                System.out.println("Expected NullPointerException thrown = " + npe);
                System.out.println("GetByteArrayTestTest02() Pass");
            } catch(Exception e) {
                System.out.println("Exception thrown = " + e);
                System.out.println("GetByteArrayTestTest02() Fail");
                e.printStackTrace();
            }
          }
       
      }

            kkladkosunw Konstantin Kladko (Inactive)
            spandeorcl Shantaram Pande (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: