SofaRegistryHelper { static void parseMethodInfo(Map<String, Object> methodParameters, String method, String valueStr) { int idxSplit = valueStr.indexOf('#'); if (idxSplit < 0) { return; } int idxLeft = valueStr.indexOf('['); int idxRight = valueStr.indexOf(']'); String parameters = valueStr.substring(idxLeft + 1, idxRight); String[] kvs = parameters.split("@"); if (kvs.length > 0) { Map<String, String> tmp = new HashMap<String, String>(); for (String kvp : kvs) { String[] kv = kvp.split("#"); if (kv.length == 2) { tmp.put(kv[0], kv[1]); } } String timeout = getValue(tmp, ATTR_TIMEOUT, KEY_TIMEOUT, TIMEOUT); if (timeout != null) { removeOldKeys(tmp, ATTR_TIMEOUT, KEY_TIMEOUT, TIMEOUT); try { methodParameters.put("." + method + "." + ATTR_TIMEOUT, Integer.parseInt(timeout)); } catch (Exception e) { LOGGER.error("method timeout is invalid : {}", timeout); } } for (Map.Entry<String, String> entry : tmp.entrySet()) { methodParameters.put("." + method + "." + entry.getKey(), entry.getValue()); } } }  static String buildListDataId(AbstractInterfaceConfig config, String protocol); static String convertProviderToUrls(ProviderConfig providerConfig, ServerConfig server); static List<ProviderInfo> parseProviderInfos(List<String> urls); static ProviderInfo parseProviderInfo(String originUrl); static final String PUBLISHER_PREFIX; static final String SUBSCRIBER_PREFIX; static final String SUBSCRIBER_LIST_GROUP_ID; static final String SUBSCRIBER_CONFIG_GROUP_ID; static final String PROTOCOL_TYPE_OVERRIDE; }
@Test public void parseMethodInfo() throws Exception { Map<String, Object> map = new HashMap<String, Object>(); SofaRegistryHelper.parseMethodInfo(map, "xx", "[]"); Assert.assertTrue(map.size() == 0); map.clear(); SofaRegistryHelper.parseMethodInfo(map, "xx", "[xxxx]"); Assert.assertTrue(map.size() == 0); map.clear(); SofaRegistryHelper.parseMethodInfo(map, "xx", "[clientTimeout#5555]"); Assert.assertTrue(map.size() == 1); Assert.assertTrue(5555 == (Integer) map.get(".xx.timeout")); map.clear(); SofaRegistryHelper.parseMethodInfo(map, "xx", "[_AUTORECONNECT#false@_TIMEOUT#2000]"); Assert.assertTrue(map.size() == 2); Assert.assertTrue(2000 == (Integer) map.get(".xx.timeout")); Assert.assertTrue("false".equals(map.get(".xx._AUTORECONNECT"))); map.clear(); SofaRegistryHelper.parseMethodInfo(map, "xx", "[clientTimeout#4444@retries#3]"); Assert.assertTrue(map.size() == 2); Assert.assertTrue(4444 == (Integer) map.get(".xx.timeout")); Assert.assertTrue("3".equals(map.get(".xx.retries"))); }