DestinationsCollection: synchronize shuttingDown flag

ShuttingDown flag is used to notify all other threads that
the collection of replication destinations is about to be stopped.

For instance, the auto-reload background thread should be informed
to not reload the configuration during shutdowns.
Having the flag as synchronized make sure that the flag is not
read and written concurrently by the shutdown and reload threads.

Change-Id: I6aa0a38d2c79a77befa5fde84da3377a1b0e7e93
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/DestinationsCollection.java b/src/main/java/com/googlesource/gerrit/plugins/replication/DestinationsCollection.java
index 123edb9..a1f0095 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/DestinationsCollection.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/DestinationsCollection.java
@@ -59,7 +59,7 @@
   private final Provider<ReplicationQueue> replicationQueue;
   private volatile ReplicationFileBasedConfig replicationConfig;
   private volatile List<Destination> destinations;
-  private volatile boolean shuttingDown;
+  private boolean shuttingDown;
 
   public static class EventQueueNotEmptyException extends Exception {
     private static final long serialVersionUID = 1L;
@@ -188,7 +188,9 @@
    */
   @Override
   public int shutdown() {
-    shuttingDown = true;
+    synchronized (this) {
+      shuttingDown = true;
+    }
 
     int discarded = 0;
     for (Destination cfg : destinations) {