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

LTP: Encoder.setPersistenceDelegate works incorrectly for null type.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description

      Name: dsR10051 Date: 06/07/2001


      The method
      java.beans.Encoder.setPersistenceDelegate(Class type, PersistenceDelegate persistenceDelegate)
      works incorrectly if value of type parameter is null.
      In this case it throws NullPointerException while
      Encoder.getPersistentDelegate(Class type)
      returns internal persistence delegate for null parameter.
      So, user can not set own PersistentDelegate in this case.
      It should be fixed or documented.

      Here is minimized test:
      import java.beans.*;

      public class EncoderTest01 {

          public static void main(String[] args) {
              Encoder enc = new Encoder();
              Class type = null;
              PersistenceDelegate nullPD = enc.getPersistenceDelegate(type);
              System.out.println(nullPD);
              enc.setPersistenceDelegate(type, nullPD);
              System.out.println("OKAY");
          }
      }
      --- Output ---
      $java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
      $java EncoderTest01
      java.beans.NullPersistenceDelegate@74a24a
      Exception in thread "main" java.lang.NullPointerException
              at java.util.Hashtable.get(Hashtable.java:320)
              at java.beans.MetaData.getBeanInfo(MetaData.java:801)
              at java.beans.MetaData.setPersistenceDelegate(MetaData.java:728)
              at java.beans.Encoder.setPersistenceDelegate(Encoder.java:154)
              at EncoderTest01.main(EncoderTest01.java:10)

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              malenkov Sergey Malenkov (Inactive)
              Reporter:
              sdasunw Sda Sda (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: