Skip to content

Commit

Permalink
Fix ConcurrentModificationException (#4426)
Browse files Browse the repository at this point in the history
Fix issue #4422
  • Loading branch information
andxu authored Jun 3, 2020
1 parent 6a46ec5 commit 6a979b4
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@
import com.microsoft.azure.management.resources.Subscription;
import com.microsoft.azure.management.resources.Tenant;
import com.microsoft.azuretools.authmanage.Environment;
import com.microsoft.azuretools.azurecommons.helpers.AzureCmdException;
import com.microsoft.azuretools.utils.Pair;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import static com.microsoft.azuretools.authmanage.Environment.*;

Expand All @@ -48,8 +47,8 @@ public abstract class AzureManagerBase implements AzureManager {
private static final String CHINA_SCM_SUFFIX = ".scm.chinacloudsites.cn";
private static final String GLOBAL_SCM_SUFFIX = ".scm.azurewebsites.net";

protected Map<String, Azure> sidToAzureMap = new HashMap<>();
protected Map<String, AppPlatformManager> sidToAzureSpringCloudManagerMap = new HashMap<>();
protected Map<String, Azure> sidToAzureMap = new ConcurrentHashMap<>();
protected Map<String, AppPlatformManager> sidToAzureSpringCloudManagerMap = new ConcurrentHashMap<>();

@Override
public String getPortalUrl() {
Expand Down Expand Up @@ -82,7 +81,7 @@ public String getScmSuffix() {
@Override
public String getTenantIdBySubscription(String subscriptionId) throws IOException {
final Pair<Subscription, Tenant> subscriptionTenantPair = getSubscriptionsWithTenant().stream()
.filter(pair -> pair!= null && pair.first() != null && pair.second() != null)
.filter(pair -> pair != null && pair.first() != null && pair.second() != null)
.filter(pair -> StringUtils.equals(pair.first().subscriptionId(), subscriptionId))
.findFirst().orElseThrow(() -> new IOException("Failed to find storage subscription id"));
return subscriptionTenantPair.second().tenantId();
Expand Down

0 comments on commit 6a979b4

Please sign in to comment.