Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-4031

Unreferenced properties created by the BasicTransformer (fix for MGNLUI-2494 has side effects)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • None
    • 5.3.10
    • dialogs
    • None
    • Linux (Ubuntu 15.10), Java 7

      The fix for MGNLUI-2494 introduced an attempt to fix a type consistency issue while replacing a property on an item. The code in question (BasicTransformer@156):

      property = new DefaultProperty<T>(type, value);
      // This will replace the previous property (with the wrong type) with the new one (correctly typed).
      relatedFormItem.addItemProperty(propertyName, property);
      

      As the comment mentions this code assumes that the original property will be replaced while calling addItemProperty. I couldn't see any indication of this within the Vaadin documentation which clearly says that a new property will be added.
      If someone runs into this section when the relatedFormItem is of type PropertysetItem (or a descendent such as BeanItem) this will cause problems.
      Calling addItemProperty in these instances won't have any effect as PropertysetItem won't allow to add the new property which is therefore not linked to the relatedFormItem.
      The new and unreferenced property with the fixed type is being returned and might get used by the caller without having any real effect since it's not referenced by the relatedFormItem.

      This is somewhat problematic since it's hard to notice. Each call to getOrCreateProperty(Class<T> type) might give an unreferenced property so these locations must be investigated (it's probably a good idea to check JIRA first).

      One quick fix might be the removal of the property which then essentially implements the replacement operation.

      If I find the time I will try to create a small project in order to provide an error causing example.

        Acceptance criteria

              Unassigned Unassigned
              costamojan Daniel Kasmeroglu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD