jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Woonsan Ko (JIRA)" <j...@apache.org>
Subject [jira] Created: (JCR-2022) A protected getter method without FIELD annotation can make NPE.
Date Fri, 13 Mar 2009 10:47:50 GMT
A protected getter method without FIELD annotation can make NPE.
----------------------------------------------------------------

                 Key: JCR-2022
                 URL: https://issues.apache.org/jira/browse/JCR-2022
             Project: Jackrabbit Content Repository
          Issue Type: Bug
    Affects Versions: 1.5.4, 1.5.5, 1.6.0
            Reporter: Woonsan Ko
             Fix For: 1.6.0
         Attachments: jackrabbit-1.6-SNAPSHOT-getter-anno.patch

If a bean is define like the following, then AnnotationDescriptorReader throws NPE.
Note that 'encodedTest' property is not annotated for internal use, but the getter method
is not public for some reason (it is possible!).

@Node
public class SimpleGetterAnnotedBaseClass {

    String path; 
    String test;
    String encodedTest;
    
    @Field(path=true)
    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    } 

    @Field
    public String getTest() {
        return test;
    }

    public void setTest(String test) {
        this.test = test;
    }
    
    protected String getEncodedTest() {
        if (encodedTest == null && test != null) {
            encodedTest = "test to be encoded: " + test;
        }
        
        return encodedTest;
    }
    
    public void setEncodedTest(String encodedTest) {
        this.encodedTest = encodedTest;
    }
        
}


To avoid the NPE, AnnotationDescriptorReader must check if the propertyDescriptor.getReadMethod()
returns null.
I will post a patch for this right now.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message