Le 12/09/2014 19:33, Jacopo Cappellato a écrit :
On Sep 12, 2014, at 7:24 PM, Jacques Le Roux<[email protected]>  
wrote:

this.serviceLocations = Collections.unmodifiableList(serviceLocations);
Exactly: this pattern can only work under the assumption of the immutability of 
the serviceLocation objects; since you broke it the classes are no more thread 
safe.

Jacopo


Immutability is not required, as long as we can guarantee that all threads will 
always have the same services engines locations values.
BTW from a practical perspective this only had an impact when the -Dportoffset parameter was used. Else the services engines locations were actually not changed, once read from their "service-location"

I suggest to synchronize the content of the else code block which begins at
    List<ServiceLocation> serviceLocations = new 
ArrayList<ServiceLocation>(serviceLocationElementList.size());
and ends at
    this.serviceLocations = Collections.unmodifiableList(serviceLocations);

Since ServiceLocation.setLocation() is only used there (in OOTB code at least) we would be sure that all threads will always have the right values, even if the -Dportoffset parameter is used. The performance impact should not be huge. I guess initializing service engines is not often done, mostly (if not only, I could not verify completly) at start.

Jacques

Reply via email to