package com.amazonaws.regions; import com.amazonaws.logging.Log; import com.amazonaws.logging.LogFactory; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.List; /* loaded from: classes.dex */ public abstract class RegionUtils { public static final Log log = LogFactory.getLog("com.amazonaws.request"); public static List regions; public static synchronized List getRegions() { List list; synchronized (RegionUtils.class) { try { if (regions == null) { init(); } list = regions; } catch (Throwable th) { throw th; } } return list; } public static Region getRegion(String str) { for (Region region : getRegions()) { if (region.getName().equals(str)) { return region; } } return null; } public static synchronized void init() { synchronized (RegionUtils.class) { if (System.getProperty("com.amazonaws.regions.RegionUtils.fileOverride") != null) { try { loadRegionsFromOverrideFile(); } catch (FileNotFoundException e) { throw new RuntimeException("Couldn't find regions override file specified", e); } } if (regions == null) { initSDKRegions(); } if (regions == null) { throw new RuntimeException("Failed to initialize the regions."); } } } public static void loadRegionsFromOverrideFile() { String property = System.getProperty("com.amazonaws.regions.RegionUtils.fileOverride"); Log log2 = log; if (log2.isDebugEnabled()) { log2.debug("Using local override of the regions file (" + property + ") to initiate regions data..."); } initRegions(new FileInputStream(new File(property))); } public static void initRegions(InputStream inputStream) { try { regions = new RegionMetadataParser().parseRegionMetadata(inputStream); } catch (Exception e) { log.warn("Failed to parse regional endpoints", e); } } public static void initSDKRegions() { Log log2 = log; if (log2.isDebugEnabled()) { log2.debug("Initializing the regions with default regions"); } regions = RegionDefaults.getRegions(); } }