none
[EWSJA] ExtendedPropertyDefinition isEqualTo method working incorrectly RRS feed

  • General discussion

  • ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(UUID.fromString("0a371590-a9e2-486b-bd60-f2fcfda53b12"), "MyProperty", MapiPropertyType.String);
            ExtendedPropertyDefinition extendedPropertyDefinition2 = new ExtendedPropertyDefinition(UUID.fromString("0a371590-a9e2-486b-bd60-f2fcfda53b9e"), "MyProperty", MapiPropertyType.String);
            PropertySet propertySet = new PropertySet(BasePropertySet.FirstClassProperties, extendedPropertyDefinition, extendedPropertyDefinition2);

    ...

    contact = Contact.bind(service, item.getId(), propertySet);

     

    Following code produces NullPointerException. This also happens if you want to add 2 or more ExtendedPropertyDefinition because isEqualTo is not working correctly.

    In my example id of ExtendedPropertyDefinition is not set, but propertySetId is used. So in isEqualTo the line "extPropDef1.getId().intValue() == extPropDef2.getId().intValue()" produces NullPointerException. Same thing happens viceversa.

    The correct isEqualTo should look like:

    protected static boolean isEqualTo(ExtendedPropertyDefinition extPropDef1,
                ExtendedPropertyDefinition extPropDef2) {
            return (extPropDef1 == extPropDef2) ||
            (extPropDef1 != null && extPropDef2 != null
                     && extPropDef1.getId() == extPropDef2.getId()
                     && extPropDef1.getMapiType() == extPropDef2.getMapiType()
                     && extPropDef1.getTag() == extPropDef2.getTag()
                     && extPropDef1.getName().equals(extPropDef2.getName())
                     && extPropDef1.getPropertySet() == extPropDef2.getPropertySet()
                     && ((extPropDef1.propertySetId == null && extPropDef2.propertySetId == null) || (extPropDef1.propertySetId != null && extPropDef1.propertySetId.equals(extPropDef2.propertySetId))));
        }


    • Changed type Jan Čustović Friday, April 8, 2011 9:19 AM Bug in API
    Friday, April 8, 2011 9:18 AM