Community
Participate
Working Groups
Build Identifier: 201005251253 If a constraint registered via the XMLConstraintProvider uses the putCurrentConstraintData() method on the AbstractValidationContext the first time its validate() method is called the data stored in the AbstractValidationContext can not be retrieved in later calls to the Constraint's validate() method via the getCurrentConstraintData(). public class MyConstraint extends AbstractModelConstraint { private int fCounter = 0; public IStatus validate(IValidationConstext ctx) { if(fCounter == 0) { ctx.putCurrentConstraintData("MyData"); } else { ((String)ctx.getCurrentConstraintData()).length(); } fCounter++; } } The above Constraint will throw a NPE the second time it is being called. This due to the fact that when being called the first time the AbsttractValidationContext's currentConstraint field (which is used as storage key in the putCurrentConstraintData() method) is a AbstractConstraintProvider$ConstraintProxy. When the Constraint is called the second time the currentConstraint field of the AbstractValidationContext is a JavaConstraintParser$ConstraintAdapter. Two different objects are used as a key for storing and retrieving. Reproducible: Always
*** Bug 513438 has been marked as a duplicate of this bug. ***
Eclipse EMF Validation is moving away from this bugs.eclipse.org issue tracker to https://github.com/eclipse/emf-validation. If this issue is relevant to you and still present in the latest release: * Create a new issue at https://github.com/eclipse/emf-validation/issues/. * Use as title in GitHub the title of this Bugzilla ticket (may include the bug number or not, at your own convenience) * In the GitHub description, start with a link to this bugzilla ticket * Optionally add new content to the description if it can helps towards resolution * Update bugzilla ticket * Add to "See also" property (up right column) the link to the newly created GitHub issue * Add a comment "Migrated to <link-to-newly-created-GitHub-issue>" * Set status as CLOSED MOVED All issues that remain open will be automatically closed next week or so. Then the Bugzilla component for EMF Validation will be archived and made read-only.
EMF Validation is in maintenance mode and has very few resources available. If you feel this issue is still relevant and important enough, and are willing to actively contribute yourself (or fund someone to work on it), please re-open on GitHub at https://github.com/eclipse/emf-validation/issues