When I use a Set, bndtools complains, that there is no unbind method, even though it's specified. But, in my opinion, using a Set only fixes the symptoms, but not the source of the problem...
Using CopyOnWriteArrayList does not make any difference. Am 20.05.2017 um 19:42 schrieb Ferry Huberts: > > > On 20/05/17 18:48, Henrik Niehaus wrote: >> I noticed a behavior with SCR, which I don't understand. I'm using a >> multiple dynamic reference for a list like this: >> >> @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = >> ReferencePolicy.DYNAMIC, bind="addService", unbind="removeService") >> private List<WeatherService> services = new ArrayList<>(); > > Use a Set<> i.s.o. a List<>. > even better would probably be CopyOnWriteArraySet, depending on your > usage scenario. > >> >> This works as I expect it. All 5 instances get added to the list. >> >> At startup SCR tells me, that it would be a good idea to make this list >> volatile, which makes sense. So I tried that and ended up with 6 >> instances in my list, which I don't understand. When I set a breakpoint >> in the bind method "addService", it turns out, that the list already >> contains an element when it is called the first time. One service is >> contained twice in the list. And it is always the service, which is >> added at last. Is this intended? Am I doing something wrong? >> >> - Henrik >> >> >> _______________________________________________ >> 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