Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 341179

Summary: StackOverflow in AttributesReconcileAdapter while manually editing xml schema doc
Product: z_Archived Reporter: Dimitar Donchev <dimitar.donchev>
Component: WTP IncubatorAssignee: Dimitar Tenev <dimitar.tenev>
Status: CLOSED FIXED QA Contact: Dimitar Tenev <dimitar.tenev>
Severity: major    
Priority: P3 CC: thatnitind
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
just write xmlns
none
All exceptions after the StackOverflow
none
proposed patch none

Description Dimitar Donchev CLA 2011-03-28 19:57:09 EDT
Created attachment 192055 [details]
just write xmlns

Try to add the follwoing string to the <schema element of the attached document : 
" xmlns="" " (write it symbol by symbol).

CAUTION - SAVE YOUR CURRENT WORK, STACK OVERFLOW WILL OCCUR! ;)
Comment 1 Dimitar Donchev CLA 2011-03-28 19:57:58 EDT
Created attachment 192056 [details]
All exceptions after the StackOverflow

You should reproduce this :
Comment 2 Nitin Dahyabhai CLA 2011-04-28 01:52:05 EDT
Notified adapters are not allowed to change the model/document during their notification.  What's the reason for trying to do so?
Comment 3 Stanislav Nichev CLA 2011-06-19 03:25:15 EDT
Created attachment 198227 [details]
proposed patch

Hi Guys,

This was a very interesting issue.
Each time you start typing an attribute name, the DOM API is creating attribute. 

For example for "xmlns", we receive notifications for several attributes with names "x", "xm", ... and "xmlns". The value of the attribute is the default one: an empty string.

In the decribed test case, when we received a full attribute name we were intersted in ("xmlns") we made some checks if such namespace already existed and made some changes on it. 
Unfortunently, the EMF API updated all the DOM attributes, including the existing ones. In order to prevent that, I've added some checks for the count of the attributes. 
This solved the issue or even - preserved the first and existing value.

Also, I've decided to test the problem when deliting attribute. For example, imagine we have two attributes: "xmlns" and "xmlns:abc". When renaming "xmlns:abc" to "xmlns", the DOM is firing event for delete of "xmlns:abc" with the new value of "xmlns". Thus, we assumed that we were deleting the "xmlns" attribute and fired some emf notification, which, in turn, deleted both the attributes.
This is no longer the case, since we check the attribute count here as well.

I've not prepared a test for this issue. I'm interested in your proposals on how we can test this.

So far, we have not introduced such tests in SIE - writing in source, or at least, I'm unaware of such.

Anyway, I'm attaching the patch.

Regards,
Stanislav
Comment 4 Stanislav Nichev CLA 2011-06-19 03:26:47 EDT
Comment on attachment 198227 [details]
proposed patch

forgot to set as patch
Comment 5 Dimitar Tenev CLA 2011-07-04 01:54:42 EDT
Hi Stanislav,

Thanks for the fix. I have retested and submitted it. It seems to works fine.

Best regards,
DImitar