by synchronized. sometime, get list service will wrong

Description

I have two plug-in
p1 and p2. it install without any issue.
but when i restart server i see below error (end of description):
both plug in use Activator Incremental2PackActivator
p1 have a service implement IModelFactory and start before p2
by debug i see a issue relate synchronized.

consider some block code:
1. class DynamicServiceHolder, in constructor DynamicServiceHolder

2. class DynamicServiceHolder, in function getServices

when server start. Incremental2PackActivator run in two thread, one for plug-in p1 and one for p2.

when p1 run into block 1. it will run to line t.trackInitial() in class ServiceTracker
at same time, p2 run in to block 1. it will run over serviceTracker.open(); because serviceTracker already open by p1.
p2 will run to block 2. inside ServiceTracker have some lock control. so p2 will don't wait p1 for load service by finish t.trackInitial()
so p2 with get a empty list or a list miss some service.

Environment

None

Status

Assignee

Heng Sin Low

Reporter

Hiep Lq

Labels

Tested By

None

Priority

Critical
Configure