Commit f7071abb authored by gmantele's avatar gmantele
Browse files

[UWS] Fix bug with JobObserver. The notification of all observers was not

synchronized although the collection of observers is synchronized (Vector) ;
using an Iterator ensures the synchronization and avoids concurrency problems.
parent 70dc3a14
Loading
Loading
Loading
Loading
+174 −186
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ import uws.service.request.UploadFile;
 * </ul>
 *
 * @author	Gr&eacute;gory Mantelet (CDS;ARI)
 * @version	4.2 (06/2017)
 * @version	4.2 (09/2017)
 */
public class UWSJob extends SerializableUWSObject {
	private static final long serialVersionUID = 1L;
@@ -1637,21 +1637,9 @@ public class UWSJob extends SerializableUWSObject {
	 * @throws UWSException	If at least one observer can not have been updated.
	 */
	public final void notifyObservers(ExecutionPhase oldPhase){
		int i = 0;
		JobObserver observer = null;
		String errors = null;

		while(i < observers.size()){
			// Gets the observer:
			if (i == 0 && observer == null)
				observer = observers.get(i);
			else if (observer.equals(observers.get(i))){
				i++;
				if (i < observers.size())
					observer = observers.get(i);
				else
					return;
			}
		for(JobObserver observer : observers){
			// Update this observer:
			try{
				observer.update(this, oldPhase, getPhase());