Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Validation] ConstraintProxy and currentConstraintData
[Validation] ConstraintProxy and currentConstraintData [message #1755938] Thu, 09 March 2017 12:48 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 392
Registered: December 2015
Senior Member
Hey, I hope Christian can help me here..

I use ConstraintStatus.put/getCurrentConstraintData to cache some data. Now what I see is, that when my rule is run for two objects, If I put data via setCurrentConstraintData() during the first run, getCurrentConstraintData() in the second run returns null as if I hadn't put anything there.

After some digging, it turns out that the first time the rule is run, the contexts currentConstraint field is an instance of ConstraintProxy, whereas the second time, it is the actual ConstraintAdapter. The value of this field is used as a the key for constraint data so here's the issue, my data is still in the map, but with the proxy as the key, not the adapter itself..

The first time the proxy is used to validate, it replaces itself with the delegate object in the constraint list:

// AbstractConstraintProvider.ConstraintProxy, Line 137ff
// replace me with my delegate in the list of constraints, to avoid
// the delegation in future invocations and to free some memory
for (ListIterator<IModelConstraint> iter = getConstraints().listIterator();
iter.hasNext()Wink {

if (iter.next() == this) {
iter.set(delegate);
break;
}
}

Which seems to break the set/put constraint data implementation. Do I miss something here?


[Ouch, I just checked what version of EMF Validation I am actually debugging, and it's 1.4.0 from over 7 years ago, feel free to slap me in the face... (I'll delegate the slap to the releng team.... I will check the code for more recent versions]

Thanks for help,
Felix
Re: [Validation] ConstraintProxy and currentConstraintData [message #1755941 is a reply to message #1755938] Thu, 09 March 2017 13:06 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Felix,

This code hasn't changed in seven years. It's remarkable that this problem hasn't been reported until now.

I would think it best to move the proxy replacement ahead of the invocation of the delegate and, if the delegate fails and is replaced by the disabled placeholder, to replace again in that case. If you work up a Gerrit patch, I think you could expect a good response from the new EMF Services project team.

Cheers,

Christian
Re: [Validation] ConstraintProxy and currentConstraintData [message #1755950 is a reply to message #1755941] Thu, 09 March 2017 13:43 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 392
Registered: December 2015
Senior Member
Truely remarkable. I see what you mean. If I find some time, I'll try to make a patch. And how about using the constraint id as a key instead? As for a workaround, time to take out the reflection rifle. Thank you for your fast response.
Re: [Validation] ConstraintProxy and currentConstraintData [message #1756035 is a reply to message #1755950] Fri, 10 March 2017 10:01 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 392
Registered: December 2015
Senior Member
Moved to https://bugs.eclipse.org/bugs/show_bug.cgi?id=513438
Previous Topic:UML to comments ?
Next Topic:difflrents instances
Goto Forum:
  


Current Time: Thu Apr 25 05:15:00 GMT 2024

Powered by FUDForum. Page generated in 0.03690 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top