Fix "No more locations already set"
When adding a new location, check if the exchange is closed, before
checking if no-more-locations is set.  This is because no-more-locations
can be set after the exchange is closed, but locations can not be
added when closed.
@@ -129,6 +129,12 @@ public class ExchangeClient
{
requireNonNull(location, "location is null");
+ // Ignore new locations after close
+ // NOTE: this MUST happen before checking no more locations is checked
+ if (closed.get()) {
+ return;
+ }
+
// ignore duplicate locations
if (allClients.containsKey(location)) {
return;
@@ -136,11 +142,6 @@ public class ExchangeClient
checkState(!noMoreLocations, "No more locations already set");
- // ignore new locations after close
- if (closed.get()) {
- return;
- }
-
HttpPageBufferClient client = new HttpPageBufferClient(
httpClient,
maxResponseSize,
