@Test(expected=Exception.class) public void testEmptyServerString() { MongoDataSource.parseServerString(""); }
static List<ServerAddress> parseServerString(String servers) { CheckConditions.checkArgument(!StringUtils.isNullOrEmpty(servers)); ArrayList<ServerAddress> addrs = new ArrayList<ServerAddress>(); String[] serverList = servers.split(","); for (String server : serverList) { String[] pair = server.split(":"); try { if(pair.length == 1) { addrs.add(new ServerAddress(pair[0].trim())); } else if (pair.length == 2) { addrs.add(new ServerAddress(pair[0].trim(), Integer.valueOf(pair[1].trim()))); } else { throw new RuntimeException("Bad server string: " + servers); } } catch (UnknownHostException e) { throw new RuntimeException("parse server string error", e); } } return addrs; }
MongoDataSource { static List<ServerAddress> parseServerString(String servers) { CheckConditions.checkArgument(!StringUtils.isNullOrEmpty(servers)); ArrayList<ServerAddress> addrs = new ArrayList<ServerAddress>(); String[] serverList = servers.split(","); for (String server : serverList) { String[] pair = server.split(":"); try { if(pair.length == 1) { addrs.add(new ServerAddress(pair[0].trim())); } else if (pair.length == 2) { addrs.add(new ServerAddress(pair[0].trim(), Integer.valueOf(pair[1].trim()))); } else { throw new RuntimeException("Bad server string: " + servers); } } catch (UnknownHostException e) { throw new RuntimeException("parse server string error", e); } } return addrs; } }
MongoDataSource { static List<ServerAddress> parseServerString(String servers) { CheckConditions.checkArgument(!StringUtils.isNullOrEmpty(servers)); ArrayList<ServerAddress> addrs = new ArrayList<ServerAddress>(); String[] serverList = servers.split(","); for (String server : serverList) { String[] pair = server.split(":"); try { if(pair.length == 1) { addrs.add(new ServerAddress(pair[0].trim())); } else if (pair.length == 2) { addrs.add(new ServerAddress(pair[0].trim(), Integer.valueOf(pair[1].trim()))); } else { throw new RuntimeException("Bad server string: " + servers); } } catch (UnknownHostException e) { throw new RuntimeException("parse server string error", e); } } return addrs; } MongoDataSource(String servers);  MongoDataSource(String servers, int connectionsPerHost);  MongoDataSource(String servers, CMSDBConfig dbConfig);  MongoDataSource(String servers, int connectionsPerHost, ReadPreference readPreference, CMSDBConfig config); }
MongoDataSource { static List<ServerAddress> parseServerString(String servers) { CheckConditions.checkArgument(!StringUtils.isNullOrEmpty(servers)); ArrayList<ServerAddress> addrs = new ArrayList<ServerAddress>(); String[] serverList = servers.split(","); for (String server : serverList) { String[] pair = server.split(":"); try { if(pair.length == 1) { addrs.add(new ServerAddress(pair[0].trim())); } else if (pair.length == 2) { addrs.add(new ServerAddress(pair[0].trim(), Integer.valueOf(pair[1].trim()))); } else { throw new RuntimeException("Bad server string: " + servers); } } catch (UnknownHostException e) { throw new RuntimeException("parse server string error", e); } } return addrs; } MongoDataSource(String servers);  MongoDataSource(String servers, int connectionsPerHost);  MongoDataSource(String servers, CMSDBConfig dbConfig);  MongoDataSource(String servers, int connectionsPerHost, ReadPreference readPreference, CMSDBConfig config); MongoClient getMongoInstance(); @Override int hashCode(); @Override boolean equals(Object o); }
MongoDataSource { static List<ServerAddress> parseServerString(String servers) { CheckConditions.checkArgument(!StringUtils.isNullOrEmpty(servers)); ArrayList<ServerAddress> addrs = new ArrayList<ServerAddress>(); String[] serverList = servers.split(","); for (String server : serverList) { String[] pair = server.split(":"); try { if(pair.length == 1) { addrs.add(new ServerAddress(pair[0].trim())); } else if (pair.length == 2) { addrs.add(new ServerAddress(pair[0].trim(), Integer.valueOf(pair[1].trim()))); } else { throw new RuntimeException("Bad server string: " + servers); } } catch (UnknownHostException e) { throw new RuntimeException("parse server string error", e); } } return addrs; } MongoDataSource(String servers);  MongoDataSource(String servers, int connectionsPerHost);  MongoDataSource(String servers, CMSDBConfig dbConfig);  MongoDataSource(String servers, int connectionsPerHost, ReadPreference readPreference, CMSDBConfig config); MongoClient getMongoInstance(); @Override int hashCode(); @Override boolean equals(Object o);  }