Details
-
Bug
-
Resolution: Fixed
-
Major
-
5.2-milestone-1
-
Unknown
-
N/A
-
N/A
-
Description
NumberProperty#equals throws a ClassCastException instead of returning false when it is compared with a property of another type (for example a StringProperty, when an object property is stored with a different type than the one of the same object in an extension XAR):
java.lang.ClassCastException: class com.xpn.xwiki.objects.StringProperty cannot be cast to class com.xpn.xwiki.objects.NumberProperty at com.xpn.xwiki.objects.NumberProperty.equals(NumberProperty.java:111) at com.xpn.xwiki.objects.BaseCollection.equals(BaseCollection.java:839) at com.xpn.xwiki.objects.BaseObject.equals(BaseObject.java:340) at com.xpn.xwiki.doc.XWikiDocument.equalsData(XWikiDocument.java:5124) at org.xwiki.extension.xar.internal.handler.XarExtensionJobFinishedListener.maybeDeletePages(XarExtensionJobFinishedListener.java:251) at org.xwiki.extension.xar.internal.handler.XarExtensionJobFinishedListener.onEvent(XarExtensionJobFinishedListener.java:156)
As reported in XWIKI-25633, this happens for example when uninstalling a XAR extension: comparing a page with the version provided by the extension fails, so the page is kept, and the uninstall job ends with an error (logged as "Failed to load attachments", which is misleading).
BaseElement#equals does check that both elements have the same class, but NumberProperty#equals evaluates ((NumberProperty) obj).getValue() as an argument of EqualsBuilder#append, so the cast is executed even when appendSuper(super.equals(obj)) already returned false. The other property types do not have this problem since they return before casting.
Attachments
Issue Links
- relates to
-
XWIKI-9326 NumberProperty#equals throws NullPointer exception when one of the properties is null
-
- Closed
-
-
XWIKI-25633 Distribution Wizard "Orphan dependencies" step ends with an error and deletes flavor pages when upgrading a sub-wiki from 16.10.5 to 17.10.14
-
- Closed
-