[MGNLUI-4031] Unreferenced properties created by the BasicTransformer (fix for MGNLUI-2494 has side effects) Created: 07/Oct/16  Updated: 08/Mar/21  Resolved: 08/Mar/21

Status: Closed
Project: Magnolia UI
Component/s: dialogs
Affects Version/s: 5.3.10
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Daniel Kasmeroglu Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux (Ubuntu 15.10), Java 7


Issue Links:
causality
caused by MGNLUI-2494 Dialog doesn't show up in case of inc... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

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.



 Comments   
Comment by Roman Kovařík [ 08/Mar/21 ]

Closing as M5.3 has reached EOL.
https://docs.magnolia-cms.com/product-docs/Support/End-of-life-policy.html#_end_of_life

Generated at Mon Feb 12 09:12:34 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.