[Validation] ConstraintProxy and currentConstraintData [message #1755938] |
Thu, 09 March 2017 12:48 |
Felix Dorner 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() {
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 |
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03690 seconds