DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9877>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9877

BeanUtils processPropertyDescriptors is including static fields.

           Summary: BeanUtils processPropertyDescriptors is including static
                    fields.
           Product: Axis
           Version: beta-2
          Platform: All
               URL: http://www.ford.com
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Serialization/Deserialization
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The BeanSerializer uses BeanUtils to get property descriptors for java beans 
properties. BeanUtils in the processPropertyDescriptors method is including 
public final static fields to the bean property descriptors array returned by 
this method. Constants fields should not be included in the array of property 
descriptor.

partial code 
------------
            // Now look for public fields
            Field fields[] = cls.getFields();
            if (fields != null && fields.length > 0) {    
                // See if the field is in the list of properties
                // add it if not.
                for (int i=0; i < fields.length; i++) {
                    Field f = fields[i];
                    String fName = f.getName();
                    boolean found = false;
                    for (int j=0; j<pd.size() && !found; j++) {
                        String pName = 
                            ((BeanPropertyDescriptor)pd.get(i)).getName();
                        if (pName.length() == fName.length() &&
                            pName.substring(0,1).equalsIgnoreCase(
                               fName.substring(0,1))) {
                            found = pName.length() == 1 ||
                                pName.substring(1).equals(fName.substring(1));
                        }
                    }
                    if (!found) {
                        pd.add(new BeanPropertyDescriptor(f.getName(), f));
                    }
                }
            }
            myPd = new BeanPropertyDescriptor[pd.size()];
            for (int i=0; i <pd.size(); i++) {
                myPd[i] = (BeanPropertyDescriptor) pd.get(i);
            }


------
should be 
-------
            Field fields[] = cls.getFields();
            if (fields != null && fields.length > 0) {    
                // See if the field is in the list of properties
                // add it if not.
                for (int i=0; i < fields.length; i++) {
                    Field f = fields[i];
                    String fName = f.getName();
                    boolean found = false;
                    for (int j=0; j<pd.size() && !found; j++) {
                        String pName = 
                            ((BeanPropertyDescriptor)pd.get(i)).getName();
                        if (pName.length() == fName.length() &&
                            pName.substring(0,1).equalsIgnoreCase(
                               fName.substring(0,1))) {
                            found = pName.length() == 1 ||
                                pName.substring(1).equals(fName.substring(1));
                        }
                    }
                    if (!found) {
                                                if (!
java.lang.reflect.Modifier.isStatic(f.getModifiers()))
                                pd.add(new BeanPropertyDescriptor(f.getName(), 
f));
                    }
                }
            }

Reply via email to