JDK-4467303 : LTP: Encoder.setPersistenceDelegate works incorrectly for null type.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 2001-06-07
  • Updated: 2007-02-05
  • Resolved: 2007-02-05
Related Reports
Duplicate :  
Relates :  
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)

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

Comments
EVALUATION This bug is fixed together with 4968523, because that fix afftect the behavior of method Encoder.setPersistenceDelegate.
05-02-2007

EVALUATION The setPersistenceDelete(null, ..) is nonsensical since it is intended as a user settable method. Setting the persistence delagate for the null type can have bad side effects on the persistence mechanism and is not supported. The only reason that the getPersistenceDelegate returns a valid persistence delegate is for internal usage only. The developer will not get any value in examining or setting the persistence delegate for the null type. This is not a bug and should not be tested. mark.davidson@Eng 2001-07-20 Javadoc should specify the behavior of methods java.beans.Encoder.setPersistenceDelegate(Class type, PersistenceDelegate persistenceDelegate) java.beans.Encoder.getPersistenceDelegate(Class type) for null value of type parameter because in this case the behavior of accessor methods does not match each other. _________________ ###@###.### 2001-08-14
14-08-2001