public static Map<String, String> string2messageProperties(final String properties) {
        Map<String, String> map = new HashMap<>(128);
        if (properties != null) {
            int len = properties.length();
            int index = 0;
            while (index < len) {
                int newIndex = properties.indexOf(PROPERTY_SEPARATOR, index);
                if (newIndex < 0) {
                    newIndex = len;
                }
                if (newIndex - index >= 3) {
                    int kvSepIndex = properties.indexOf(NAME_VALUE_SEPARATOR, index);
                    if (kvSepIndex > index && kvSepIndex < newIndex - 1) {
                        String k = properties.substring(index, kvSepIndex);
                        String v = properties.substring(kvSepIndex + 1, newIndex);
                        map.put(k, v);
                    }
                }
                index = newIndex + 1;
            }
        }

        return map;
    }
@Test
    public void testString2messageProperties() {
        StringBuilder sb = new StringBuilder();
        sb.append("k1").append(NAME_VALUE_SEPARATOR).append("v1");
        Map<String,String> m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(1);
        assertThat(m.get("k1")).isEqualTo("v1");

        m = MessageDecoder.string2messageProperties("");
        assertThat(m).size().isEqualTo(0);

        m = MessageDecoder.string2messageProperties(" ");
        assertThat(m).size().isEqualTo(0);

        m = MessageDecoder.string2messageProperties("aaa");
        assertThat(m).size().isEqualTo(0);

        sb.setLength(0);
        sb.append("k1").append(NAME_VALUE_SEPARATOR);
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(0);

        sb.setLength(0);
        sb.append(NAME_VALUE_SEPARATOR).append("v1");
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(0);

        sb.setLength(0);
        sb.append("k1").append(NAME_VALUE_SEPARATOR).append("v1").append(PROPERTY_SEPARATOR);
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(1);
        assertThat(m.get("k1")).isEqualTo("v1");

        sb.setLength(0);
        sb.append("k1").append(NAME_VALUE_SEPARATOR).append("v1").append(PROPERTY_SEPARATOR)
                .append("k2").append(NAME_VALUE_SEPARATOR).append("v2");
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(2);
        assertThat(m.get("k1")).isEqualTo("v1");
        assertThat(m.get("k2")).isEqualTo("v2");

        sb.setLength(0);
        sb.append("k1").append(NAME_VALUE_SEPARATOR).append("v1").append(PROPERTY_SEPARATOR)
                .append(NAME_VALUE_SEPARATOR).append("v2");
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(1);
        assertThat(m.get("k1")).isEqualTo("v1");

        sb.setLength(0);
        sb.append("k1").append(NAME_VALUE_SEPARATOR).append("v1").append(PROPERTY_SEPARATOR)
                .append("k2").append(NAME_VALUE_SEPARATOR);
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(1);
        assertThat(m.get("k1")).isEqualTo("v1");

        sb.setLength(0);
        sb.append(NAME_VALUE_SEPARATOR).append("v1").append(PROPERTY_SEPARATOR)
                .append("k2").append(NAME_VALUE_SEPARATOR).append("v2");
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(1);
        assertThat(m.get("k2")).isEqualTo("v2");

        sb.setLength(0);
        sb.append("k1").append(NAME_VALUE_SEPARATOR).append(PROPERTY_SEPARATOR)
                .append("k2").append(NAME_VALUE_SEPARATOR).append("v2");
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(1);
        assertThat(m.get("k2")).isEqualTo("v2");

        sb.setLength(0);
        sb.append("1").append(NAME_VALUE_SEPARATOR).append("1").append(PROPERTY_SEPARATOR)
                .append("2").append(NAME_VALUE_SEPARATOR).append("2");
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(2);
        assertThat(m.get("1")).isEqualTo("1");
        assertThat(m.get("2")).isEqualTo("2");

        sb.setLength(0);
        sb.append("1").append(NAME_VALUE_SEPARATOR).append(PROPERTY_SEPARATOR)
                .append("2").append(NAME_VALUE_SEPARATOR).append("2");
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(1);
        assertThat(m.get("2")).isEqualTo("2");

        sb.setLength(0);
        sb.append(NAME_VALUE_SEPARATOR).append("1").append(PROPERTY_SEPARATOR)
                .append("2").append(NAME_VALUE_SEPARATOR).append("2");
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(1);
        assertThat(m.get("2")).isEqualTo("2");

        sb.setLength(0);
        sb.append("1").append(NAME_VALUE_SEPARATOR).append("1").append(PROPERTY_SEPARATOR)
                .append("2").append(NAME_VALUE_SEPARATOR);
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(1);
        assertThat(m.get("1")).isEqualTo("1");

        sb.setLength(0);
        sb.append("1").append(NAME_VALUE_SEPARATOR).append("1").append(PROPERTY_SEPARATOR)
                .append(NAME_VALUE_SEPARATOR).append("2");
        m = MessageDecoder.string2messageProperties(sb.toString());
        assertThat(m).size().isEqualTo(1);
        assertThat(m.get("1")).isEqualTo("1");
    }