Details
-
Bug
-
Resolution: Won't Fix
-
Low
-
None
-
5.0.2
Description
This is the underlying cause of CONF-28553, which was fixed by adding a specific guard condition when importing the invalid LikeEntity.
We should prevent invalid XML entities from being included in the export in the first place. The results of aragot's investigation while reviewing the fix for CONF-28553 are below.
That's a problem located in com.atlassian.hibernate.extras.XMLDatabinder#excludeClass(). At export time, the following call fails at excluding the Like when the compulsory ContentEntityObject is missing:
if (context != null && !context.isExportComments()) { databinder.excludeClass(Comment.class); }
If you look how excluded classes are used, you find isExcludedAsProperty() in:
private void renderProperty(Writer writer, String name, Type type, Object value, String componentName, String propertyName, String collectionName, boolean doType) throws HibernateException, IOException { ... else if (type.isEntityType()) { renderEntityType(writer, name, type, value, propertyName); if (!isExcludedAsProperty(value)) associatedObjectFound(value); }
and you notice the 'if' has no 'else'. It will just forget to render the [mandatory] property, producing an invalid entity in the XML. We should probably fix that problem if we don't want to be bitten later (Note: Will only cause problem when we have a foreign key, a not-null and an excluded entity).