eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[validator] CompleteOCLEObjectValidator can be shared between editors #1965

Open eclipse-ocl-bot opened 2 hours ago

eclipse-ocl-bot commented 2 hours ago

| --- | --- | | Bugzilla Link | 532757 | | Status | NEW | | Importance | P3 normal | | Reported | Mar 22, 2018 08:06 EDT | | Modified | Oct 01, 2023 15:50 EDT | | Depends on | 582256, 582494 | | Reporter | Ed Willink |

Description

https://www.eclipse.org/forums/index.php/mv/msg/1092285/1784083/#msg_1784083 reports a CompleteOCLEObjectValidator being shared acros multiple editors becuase a single entry occurs in the EValidator.Registry.INSTANCE.

It should either be pwer-ResourceSet or per-Thread and synchronized.

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Mar 22, 2018 08:38

Searching for the CompleteOCLEObjectValidator installation there are only two examples:

ValidateTests.testValidate_Validate_completeocl

CompleteOCLEObjectValidator completeOCLEObjectValidator = new CompleteOCLEObjectValidator(validatePackage1, oclURI, ocl0.getEnvironmentFactory());\
EValidator.Registry.INSTANCE.put(validatePackage1, completeOCLEObjectValidator);

This is not the right way to do it since there is no sharing.

PivotDocumentationExamples.test_parsingDocumentsExample

ComposedEValidator newEValidator = ComposedEValidator.install(EXTLibraryPackage.eINSTANCE);\
newEValidator.addChild(new CompleteOCLEObjectValidator(\
    EXTLibraryPackage.eINSTANCE, uri, ocl.getEnvironmentFactory()));

Much better, multiple validators and PivotEObjectValidator per-ResourceSet functionality should work. But the CompleteOCLEObjectValidator override of validate() looks to break per-ResourceSet sharing.

It is unfair for each user to discover the correct way, we should probably have a static install() and make the constructor protected (@deprecated public).

eclipse-ocl-bot commented 2 hours ago

By Steve Hickman on Aug 07, 2023 15:51

Has this been resolved?

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Aug 07, 2023 16:01

Unlikely, but Bug 582256 identifies a more fundamental bug that once fixed could solve this too.

eclipse-ocl-bot commented 2 hours ago

By Ed Willink on Oct 01, 2023 15:50

(In reply to Ed Willink from comment #0)

because a single entry occurs in the EValidator.Registry.INSTANCE.

It should either be per-ResourceSet or per-Thread and synchronized.

Bug 582494 identifies the current practice of augmenting the global validator registry as a bad practice. It looks like it may not be that hard to have a kind of per-ResourceSet local validator registry that delegates to global just like the other registries.

(It seems that none of my work in the last year has yet leaked to master so there should be no problem in substantially fixing these problems in a regular next minor release.)