static URL getConfigFile()

in aws-xray-agent/src/main/java/com/amazonaws/xray/agent/runtime/AgentRuntimeLoader.java [90:113]


    static URL getConfigFile() {
        String customLocation = System.getProperty(CONFIG_FILE_SYS_PROPERTY);
        if (customLocation != null && !customLocation.isEmpty()) {
            try {
                File file = new File(customLocation);
                if (file.exists()) {
                    return file.toURI().toURL();
                } else {
                    return AgentRuntimeLoader.class.getResource(customLocation);
                }
            } catch (MalformedURLException e) {
                log.error("X-Ray agent config file's custom location was malformed. " +
                        "Falling back to default configuration.");
                return null;
            }
        }

        // Search root of classpath first, then check root of Spring Boot classpath
        URL defaultLocation = AgentRuntimeLoader.class.getResource(CONFIG_FILE_DEFAULT_LOCATION);
        if (defaultLocation == null) {
            defaultLocation = AgentRuntimeLoader.class.getResource(CONFIG_FILE_SPRING_BOOT_LOCATION);
        }
        return defaultLocation;
    }