private static void readPropertyDefinitionLine()

in src/main/java/com/aliyun/credentials/utils/ProfileUtils.java [76:103]


    private static void readPropertyDefinitionLine(ParserProgress progress, String line) {
        // Invalid profile, ignore its properties
        if (progress.ignoringCurrentProfile) {
            return;
        }
        if (progress.currentProfileBeingRead == null) {
            // throw new IllegalArgumentException(String.format("Expected a profile definition on line %s", progress.currentLineNumber));
            // To be consistent with ini4j's behavior
            progress.currentProfileBeingRead = "?";
            if (!progress.profiles.containsKey(progress.currentProfileBeingRead)) {
                progress.profiles.put(progress.currentProfileBeingRead, new LinkedHashMap<String, String>());
            }
        }

        // Comments with property must have whitespace before them, or they will be considered part of the value
        String lineWithoutComments = removeTrailingComments(line, " #", " ;", "\t#", "\t;");
        String lineWithoutWhitespace = lineWithoutComments.trim();
        Property<String, String> property = parsePropertyDefinition(progress, lineWithoutWhitespace);

        if (progress.profiles.get(progress.currentProfileBeingRead).containsKey(property.key())) {
            logger.warning("Duplicate property '" + property.key() + "' detected on line " + progress.currentLineNumber +
                    ". The later one in the file will be used.");
        }

        progress.currentPropertyBeingRead = property.key();

        progress.profiles.get(progress.currentProfileBeingRead).put(property.key(), property.value());
    }