public void updateForReplayJournal(List<Pair<String, String>> properties) {
        for (Pair<String, String> entry : properties) {
            try {
                String key = entry.first;
                String value = entry.second;
                if (key.equalsIgnoreCase(PROP_MAX_USER_CONNECTIONS)) {
                    long maxConn = checkMaxConn(value);
                    setMaxConn(maxConn);
                } else if (key.equalsIgnoreCase(PROP_DATABASE)) {
                    setDatabase(value);
                } else if (key.equalsIgnoreCase(PROP_CATALOG)) {
                    setCatalog(value);
                } else if (key.startsWith(PROP_SESSION_PREFIX)) {
                    String sessionKey = key.substring(PROP_SESSION_PREFIX.length());
                    if (sessionKey.equalsIgnoreCase(PROP_CATALOG)) {
                        setCatalog(value);
                    } else {
                        setSessionVariable(sessionKey, value);
                    }
                }
            } catch (Exception e) {
                // we should never throw an exception when replaying journal
                LOG.warn("update user property from journal failed: ", e);
            }
        }
    }
@Test
    public void testUpdateForReplayJournal() {
        try {
            // updateForReplayJournal must not throw any exception
            List<Pair<String, String>> properties = new ArrayList<>();
            properties.add(new Pair<>(UserProperty.PROP_MAX_USER_CONNECTIONS, "2000"));
            properties.add(new Pair<>(UserProperty.PROP_DATABASE, "database"));
            properties.add(new Pair<>(UserProperty.PROP_CATALOG, "catalog"));
            properties.add(new Pair<>("session.aaa", "bbb"));
            properties.add(new Pair<>("xxx", "yyy"));

            UserProperty userProperty = new UserProperty();
            userProperty.updateForReplayJournal(properties);

            Assert.assertEquals(2000, userProperty.getMaxConn());
            Assert.assertEquals("database", userProperty.getDatabase());
            Assert.assertEquals("catalog", userProperty.getCatalog());
            Map<String, String> sessionVariables = userProperty.getSessionVariables();
            Assert.assertEquals(1, sessionVariables.size());
            Assert.assertEquals("bbb", sessionVariables.get("aaa"));
        } catch (Exception e) {
            throw e;
        }

        try {
            // set the user connection to a invalid value
            List<Pair<String, String>> properties = new ArrayList<>();
            properties.add(new Pair<>(UserProperty.PROP_MAX_USER_CONNECTIONS, "200d"));
            properties.add(new Pair<>(UserProperty.PROP_DATABASE, "database"));
            properties.add(new Pair<>(UserProperty.PROP_CATALOG, "catalog"));
            properties.add(new Pair<>("session.aaa", "bbb"));
            properties.add(new Pair<>("xxx", "yyy"));

            UserProperty userProperty = new UserProperty();
            userProperty.updateForReplayJournal(properties);

            Assert.assertEquals(UserProperty.MAX_CONN_DEFAULT_VALUE, userProperty.getMaxConn());
            Assert.assertEquals("database", userProperty.getDatabase());
            Assert.assertEquals("catalog", userProperty.getCatalog());
            Map<String, String> sessionVariables = userProperty.getSessionVariables();
            Assert.assertEquals(1, sessionVariables.size());
            Assert.assertEquals("bbb", sessionVariables.get("aaa"));
        } catch (Exception e) {
            throw e;
        }
    }