IDEMPIERE-5477 Concurrency issue for the use of OSGi Service Tracker (#1563)

This commit is contained in:
hengsin 2022-11-15 21:17:02 +08:00 committed by GitHub
parent f84ca70440
commit c9f589c4d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -37,8 +37,10 @@ public class DynamicServiceHolder<T> implements IServiceHolder<T>, IServicesHold
*/
public DynamicServiceHolder(ServiceTracker<T, T> tracker) {
serviceTracker = tracker;
if (serviceTracker.getTrackingCount() == -1)
serviceTracker.open();
synchronized (serviceTracker) {
if (serviceTracker.getTrackingCount() == -1)
serviceTracker.open();
}
}
@Override