Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330038 - IndexOutOfBoundsException in gallery sample
Summary: IndexOutOfBoundsException in gallery sample
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Sapphire (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Konstantin Komissarchik CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-11 14:45 EST by Konstantin Komissarchik CLA
Modified: 2021-11-19 09:21 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Komissarchik CLA 2010-11-11 14:45:18 EST
Reported by Ling Hao:
=====================

Case 1:

1. sapphire-gallery.xml -> List property editor 
2. add a reference
3. edit the reference and clear the content and get the exception. 

Case 2:

1. sapphire-gallery.xml -> Actions 
2. add a name
3. edit the name and clear the content and get the exception. 
 
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at org.eclipse.sapphire.modeling.xml.XmlPath.getSegment(XmlPath.java:97)
at org.eclipse.sapphire.modeling.xml.XmlElement.removeChildNode(XmlElement.java:797)
at org.eclipse.sapphire.modeling.xml.XmlElement.removeChildNode(XmlElement.java:788)
at org.eclipse.sapphire.modeling.xml.XmlElement.setChildNodeText(XmlElement.java:771)
at org.eclipse.sapphire.modeling.xml.StandardXmlValueBindingImpl.write(StandardXmlValueBindingImpl.java:161)
Comment 1 Konstantin Komissarchik CLA 2010-11-11 14:47:50 EST
The initial fix is to adjust xml binding specification:

The following change is necessary to the Name property in IValuePropertyActionsGalleryReference and IValuePropertyActionsGalleryEntity.

Original: @XmlBinding( path = "" )
Fix: @XmlValueBinding( path = "", removeNodeOnSetIfNull = false )

Explanation of the problem:

What’s going on is that default xml value binding will remove bound XML node when the property is set to null. This is generally appropriate, but in this case the property is bound to the same XML element as its parent model element (path="" specification). Removing the xml element causes havoc for the parent model element.

Leaving this bug open to track making xml binding smarter to avoid this situation in the first place.
Comment 2 Konstantin Komissarchik CLA 2010-12-01 17:53:55 EST
Fixed the underlying issue and reverted the workarounds in samples. The real fix was to ignore removeNodeOnSetIfNull setting if path is empty (self reference).
Comment 3 Ling Hao CLA 2011-01-05 16:43:24 EST
Verified.