private static void readSectionDefinitionLine()

in src/main/java/com/aliyun/credentials/utils/ProfileUtils.java [54:74]


    private static void readSectionDefinitionLine(ParserProgress progress, String line) {
        String lineWithoutComments = removeTrailingComments(line, "#", ";");
        String lineWithoutWhitespace = lineWithoutComments.trim();

        if (!lineWithoutWhitespace.endsWith("]")) {
            throw new IllegalArgumentException(String.format("Section definition must end with ']' on line %s: %s", progress.currentLineNumber, line));
        }

        String lineWithoutBrackets = lineWithoutWhitespace.substring(1, lineWithoutWhitespace.length() - 1);
        String profileName = lineWithoutBrackets.trim();
        if (profileName.isEmpty()) {
            progress.ignoringCurrentProfile = true;
            return;
        }
        progress.currentProfileBeingRead = profileName;
        progress.currentPropertyBeingRead = null;
        progress.ignoringCurrentProfile = false;
        if (!progress.profiles.containsKey(profileName)) {
            progress.profiles.put(profileName, new LinkedHashMap<String, String>());
        }
    }