static Map<String, String> parseAgentArgs(final String agentArgs)
    {
        if (Strings.isEmpty(agentArgs))
        {
            throw new IllegalArgumentException("cannot parse empty value");
        }

        final Map<String, String> values = new HashMap<>();

        int optionIndex = -1;
        do
        {
            final int valueIndex = agentArgs.indexOf(VALUE_SEPARATOR, optionIndex);
            if (valueIndex <= 0)
            {
                break;
            }

            int nameIndex = -1;
            while (optionIndex < valueIndex)
            {
                nameIndex = optionIndex;
                optionIndex = agentArgs.indexOf(OPTION_SEPARATOR, optionIndex + 1);
                if (optionIndex < 0)
                {
                    break;
                }
            }

            final String optionName = agentArgs.substring(nameIndex + 1, valueIndex);
            final String value = agentArgs.substring(
                valueIndex + 1,
                optionIndex > 0 ? optionIndex : agentArgs.length());
            values.put(optionName, value);
        }
        while (optionIndex > 0);

        return values;
    }
@Test
    void shouldParseAgentArgsThatEndWithExtraSeparators()
    {
        final Map<String, String> expectedOptions = new HashMap<>();
        expectedOptions.put(ENABLED_ARCHIVE_EVENT_CODES, "REPLICATION_SESSION_STATE_CHANGE,CMD_IN_START_RECORDING");

        final Map<String, String> configOptions = parseAgentArgs(
            "aeron.event.archive.log=REPLICATION_SESSION_STATE_CHANGE,CMD_IN_START_RECORDING||||");

        assertEquals(expectedOptions, configOptions);
    }