Thats is not a safe collection type. Why not let DS manage the field?
 
If you need to use a final field, then you need to use a thread safe collection.
--

BJ Hargrave
Senior Technical Staff Member, IBM // office: +1 386 848 1781
OSGi Fellow and CTO of the OSGi Alliance // mobile: +1 386 848 3788
hargr...@us.ibm.com
 
 
----- Original message -----
From: "Leschke, Scott" <slesc...@medline.com>
Sent by: osgi-dev-boun...@mail.osgi.org
To: "osgi-dev@mail.osgi.org" <osgi-dev@mail.osgi.org>
Cc:
Subject: [osgi-dev] Regarding Collection references
Date: Thu, Jul 20, 2017 4:50 PM
 

If I have a reference in an SCR component like the following,

 

@Reference(policy = ReferencePolicy.DYNAMIC)

private final Collection<MyServiceType> factories = new java.util.ArrayList<>();

 

Since the collection is updated by the runtime as services come and go, I assume it’s prudent to synchronize

on the collection when iterating over it whereas in Blueprint I got the impression this wasn’t necessary.

 

Would that be correct?

 

Scott Leschke

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev
 

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to