Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319511 - Regression: Multiple advice with same signature on same template don't work
Summary: Regression: Multiple advice with same signature on same template don't work
Status: CLOSED FIXED
Alias: None
Product: M2T
Classification: Modeling
Component: Xpand (show other bugs)
Version: 1.0.0   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: SR1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-12 03:35 EDT by Achim Demelt CLA
Modified: 2013-02-21 08:12 EST (History)
1 user (show)

See Also:
sebastian.zarnekow: helios+


Attachments
Test case for this regression (3.67 KB, patch)
2010-07-12 03:35 EDT, Achim Demelt CLA
no flags Details | Diff
Proposed patch (901 bytes, patch)
2010-07-12 03:36 EDT, Achim Demelt CLA
no flags Details | Diff
Updated Patch (886 bytes, patch)
2010-07-23 05:13 EDT, Achim Demelt CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Achim Demelt CLA 2010-07-12 03:35:34 EDT
Created attachment 173996 [details]
Test case for this regression

This constellation worked in 0.7.0 but fails with 1.0.0:

Foo.xpt:
«DEFINE foo FOR Object»«ENDDEFINE»

Advice1.xpt
«AROUND *foo FOR Object»A«ENDDEFINE»

Advice2.xpt
«AROUND *foo FOR Object»B«ENDDEFINE»

Activating both advice will yield "A" instead of "AB". The second advice is not applied.

This regression was introduced by the addition of the toString() method in Advice.java. Since the equals() operation in AbstractDefinition.java is based on toString(), two Advice with the same signature on the same template are regarded as equal, although they come from different sources and have different bodies.

Attached is a test case for this constellation as well as a proposed fix: The equals() method now also takes into account the body of the advice.

If everybody's ok with this, I'll commit this fix to HEAD as well as Helios SR1.
Comment 1 Achim Demelt CLA 2010-07-12 03:36:00 EDT
Created attachment 173997 [details]
Proposed patch
Comment 2 Sebastian Zarnekow CLA 2010-07-23 05:00:41 EDT
I don't think that the body is a good criteria for equal advices. As this is a regression, I'ld like to restore the old behavior and consider getOwner().getFullyQualfiiedName() as a indicator for equal advices. Don't forget to implement #hashCode()
Comment 3 Achim Demelt CLA 2010-07-23 05:13:06 EDT
Created attachment 175044 [details]
Updated Patch

Updated patch that uses the owner of an Advice in the equals() method instead of the body. Now also overrides hashCode().
Comment 4 Achim Demelt CLA 2010-07-30 08:29:53 EDT
Patch committed to HEAD.
Comment 5 Karsten Thoms CLA 2013-02-21 08:12:11 EST
Bug resolved before Xpand 1.2 release date => Closing