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

Bug 323384

Summary: Synchronization problem in ModelValidationService / LazyListener
Product: [Modeling] EMF Services Reporter: Martina Galabova <martina.galabova>
Component: ValidationAssignee: EMF Services Validation inbox <emfservices.validation-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3 CC: eclipse.me, pierre-charles.david
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
error that was logged none

Description Martina Galabova CLA 2010-08-23 08:49:11 EDT
Build Identifier: 1.4.0.v201002260347-479-9oB5855BBN5EHQ (build ID itself was "@build@")

Hi, 
 
 Synchronization problem can occur with the following scenario - there is a registered validator MyValidator, with no scheduling rule and there are two instances, triggered at the same time (e.g. build is triggered and two instances of MyValidator are initialized and two Jobs are created and scheduled). This validators should be triggered in parallel threads, so org.eclipse.emf.validation.service.ModelValidationService$LazyListener.replaceMe(ModelValidationService.java:766) will be called twice. And in the second call indexOf(this) will return -1 (because this validator was already replaced) and ArrayIndexOutOfBoundsException will be thrown and logged in Error log view.
 This is a rare case, but still possible. The only visible problem is logged exception. Could you please investigate this?

Thanks and best regards,
Martina Galabova


Reproducible: Sometimes

Steps to Reproduce:
1. Create and register validator
2. Try to create a situation, that this validator is called twice for one build
3. See error log view for details
Comment 1 Martina Galabova CLA 2010-08-23 09:09:25 EDT
Created attachment 177212 [details]
error that was logged
Comment 2 Michael Tiller CLA 2016-02-15 05:32:07 EST
Issue is still present with EMF Validation 1.8.0.

We're starting a lot of jobs (40+) that each validate 1 or 2 objects of the model, and the ArrayIndexOutOfBoundsException is triggered quite often.

---
java.lang.ArrayIndexOutOfBoundsException: -1
	at org.eclipse.emf.validation.service.ModelValidationService$LazyListener.replaceMe(ModelValidationService.java:766)
	at org.eclipse.emf.validation.service.ModelValidationService$LazyListener.validationOccurred(ModelValidationService.java:787)
	at org.eclipse.emf.validation.service.ModelValidationService.broadcastValidationEvent(ModelValidationService.java:446)
	at org.eclipse.emf.validation.internal.service.AbstractValidator.validate(AbstractValidator.java:167)
	at org.eclipse.emf.validation.internal.service.AbstractValidator.validate(AbstractValidator.java:126)
	at org.eclipse.emf.validation.internal.service.BatchValidator.validate(BatchValidator.java:117)
	at org.polarsys.kitalpha.validation.ocl.provider.generic.EValidatorAdapter.validate(EValidatorAdapter.java:117)
	at org.eclipse.emf.ecore.util.Diagnostician.doValidate(Diagnostician.java:171)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:158)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:108)
---
Comment 3 Pierre-Charles David CLA 2022-05-14 09:53:18 EDT
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.
Comment 4 Pierre-Charles David CLA 2022-05-26 15:31:07 EDT
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