@Test(expected = IllegalArgumentException.class) public void testMultipleEqualsSignsWithNoDelimeter() { InfluxDBJvmTagParser.parse("tag1=value1 tag2=value2"); }
public static Map<String, String> parse(String jvmTags) throws IllegalArgumentException { if (jvmTags == null || jvmTags.isEmpty()) { return Collections.EMPTY_MAP; } String[] tagValuePairs = jvmTags.split(","); Map<String, String> result = new HashMap<>(); for (String tagValuePair : tagValuePairs) { String[] tagValueSplit = tagValuePair.split("="); if (tagValueSplit.length != 2) { throw new IllegalArgumentException("jvmTags is in an invalid format. " + "Multiple Tag/Value pairs must be delimited by ','. " + "A tag/value pair must be separated with an '='. jvmTag input was '" + jvmTags + "'"); } String tagName = tagValueSplit[0]; if (tagName.isEmpty()) { throw new IllegalArgumentException("A tag name is empty. jvmTag input was '" + jvmTags + "'"); } String value = tagValueSplit[1]; if (value.isEmpty()) { throw new IllegalArgumentException("The tag value for tag name '" + tagName + "' is empty. Full jvmTag input was '" + jvmTags + "'"); } result.put(tagName, value); } return result; }
InfluxDBJvmTagParser { public static Map<String, String> parse(String jvmTags) throws IllegalArgumentException { if (jvmTags == null || jvmTags.isEmpty()) { return Collections.EMPTY_MAP; } String[] tagValuePairs = jvmTags.split(","); Map<String, String> result = new HashMap<>(); for (String tagValuePair : tagValuePairs) { String[] tagValueSplit = tagValuePair.split("="); if (tagValueSplit.length != 2) { throw new IllegalArgumentException("jvmTags is in an invalid format. " + "Multiple Tag/Value pairs must be delimited by ','. " + "A tag/value pair must be separated with an '='. jvmTag input was '" + jvmTags + "'"); } String tagName = tagValueSplit[0]; if (tagName.isEmpty()) { throw new IllegalArgumentException("A tag name is empty. jvmTag input was '" + jvmTags + "'"); } String value = tagValueSplit[1]; if (value.isEmpty()) { throw new IllegalArgumentException("The tag value for tag name '" + tagName + "' is empty. Full jvmTag input was '" + jvmTags + "'"); } result.put(tagName, value); } return result; } }
InfluxDBJvmTagParser { public static Map<String, String> parse(String jvmTags) throws IllegalArgumentException { if (jvmTags == null || jvmTags.isEmpty()) { return Collections.EMPTY_MAP; } String[] tagValuePairs = jvmTags.split(","); Map<String, String> result = new HashMap<>(); for (String tagValuePair : tagValuePairs) { String[] tagValueSplit = tagValuePair.split("="); if (tagValueSplit.length != 2) { throw new IllegalArgumentException("jvmTags is in an invalid format. " + "Multiple Tag/Value pairs must be delimited by ','. " + "A tag/value pair must be separated with an '='. jvmTag input was '" + jvmTags + "'"); } String tagName = tagValueSplit[0]; if (tagName.isEmpty()) { throw new IllegalArgumentException("A tag name is empty. jvmTag input was '" + jvmTags + "'"); } String value = tagValueSplit[1]; if (value.isEmpty()) { throw new IllegalArgumentException("The tag value for tag name '" + tagName + "' is empty. Full jvmTag input was '" + jvmTags + "'"); } result.put(tagName, value); } return result; }  }
InfluxDBJvmTagParser { public static Map<String, String> parse(String jvmTags) throws IllegalArgumentException { if (jvmTags == null || jvmTags.isEmpty()) { return Collections.EMPTY_MAP; } String[] tagValuePairs = jvmTags.split(","); Map<String, String> result = new HashMap<>(); for (String tagValuePair : tagValuePairs) { String[] tagValueSplit = tagValuePair.split("="); if (tagValueSplit.length != 2) { throw new IllegalArgumentException("jvmTags is in an invalid format. " + "Multiple Tag/Value pairs must be delimited by ','. " + "A tag/value pair must be separated with an '='. jvmTag input was '" + jvmTags + "'"); } String tagName = tagValueSplit[0]; if (tagName.isEmpty()) { throw new IllegalArgumentException("A tag name is empty. jvmTag input was '" + jvmTags + "'"); } String value = tagValueSplit[1]; if (value.isEmpty()) { throw new IllegalArgumentException("The tag value for tag name '" + tagName + "' is empty. Full jvmTag input was '" + jvmTags + "'"); } result.put(tagName, value); } return result; }  static Map<String, String> parse(String jvmTags); }
InfluxDBJvmTagParser { public static Map<String, String> parse(String jvmTags) throws IllegalArgumentException { if (jvmTags == null || jvmTags.isEmpty()) { return Collections.EMPTY_MAP; } String[] tagValuePairs = jvmTags.split(","); Map<String, String> result = new HashMap<>(); for (String tagValuePair : tagValuePairs) { String[] tagValueSplit = tagValuePair.split("="); if (tagValueSplit.length != 2) { throw new IllegalArgumentException("jvmTags is in an invalid format. " + "Multiple Tag/Value pairs must be delimited by ','. " + "A tag/value pair must be separated with an '='. jvmTag input was '" + jvmTags + "'"); } String tagName = tagValueSplit[0]; if (tagName.isEmpty()) { throw new IllegalArgumentException("A tag name is empty. jvmTag input was '" + jvmTags + "'"); } String value = tagValueSplit[1]; if (value.isEmpty()) { throw new IllegalArgumentException("The tag value for tag name '" + tagName + "' is empty. Full jvmTag input was '" + jvmTags + "'"); } result.put(tagName, value); } return result; }  static Map<String, String> parse(String jvmTags);  }