openhab-core/bundles/org.openhab.core.model.core
Markus Rathgeb f881ef87f1 model: prevent simultan access of singleton (#773)
The singleton instance of "Diagnostician" is used without
synchronization.
The singleton "Diasnostician" instance is using the singleton
"EValidator.Registry" instance (without synchronization).
In very rare high load situations there has been CME detected.

My first "solution" has been to synchronize the access of
Diagnostician's instance method by using

```java
synchronized (Diagnostician.INSTANCE) {
    ...
```

But after realize that EMF is using internally other singletons I tried
to find any information about EMF and thread safety.

I found this one: https://javahacks.net/2016/07/13/emf-thread-safety/

  EMF models are not thread-safe by default and writing multithreaded
  applications is not that simple.
  The more complex our application became, the more often we got
  concurrent modification exceptions and had problems with filtering and
  sorting operations.

So, I assume instead of adding synchronizations to our code that is
using EMF (IIRC this has been already done on the ESH hosted code base
long time ago) we should try to execute EMF code in a safe manner.

This implementation adds a "SafeEMF" OSGi service that should be used to
execute EMF code to ensure none code of EMF (or at least the ones that
calls has been migrated to the SafeEMF usage) is accessed by separate
threads at the same time.

Related to: https://github.com/openhab/openhab-core/issues/772

Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
2019-05-01 23:19:07 +02:00
..
src/main/java/org/eclipse/smarthome/model/core model: prevent simultan access of singleton (#773) 2019-05-01 23:19:07 +02:00
.classpath mavenize openHAB and integrate mavenized ESH repository (#467) 2019-01-28 13:07:31 +01:00
.project mavenize openHAB and integrate mavenized ESH repository (#467) 2019-01-28 13:07:31 +01:00
bnd.bnd mavenize openHAB and integrate mavenized ESH repository (#467) 2019-01-28 13:07:31 +01:00
model.profile-marker mavenize openHAB and integrate mavenized ESH repository (#467) 2019-01-28 13:07:31 +01:00
NOTICE Updated NOTICE files to openHAB (#578) 2019-02-15 10:46:18 +01:00
pom.xml mavenize openHAB and integrate mavenized ESH repository (#467) 2019-01-28 13:07:31 +01:00