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

Bug 319511

Summary: Regression: Multiple advice with same signature on same template don't work
Product: [Modeling] M2T Reporter: Achim Demelt <achim.demelt>
Component: XpandAssignee: Project Inbox <m2t.xpand-inbox>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: sebastian.zarnekow
Version: 1.0.0Flags: sebastian.zarnekow: helios+
Target Milestone: SR1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Test case for this regression
none
Proposed patch
none
Updated Patch none

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