Commit e994971b by Jon Schneider

Minor improvements to error messages for netflix.atlas.uri problems

parent 0ddfb42d
......@@ -95,9 +95,14 @@ public class AtlasMetricObserver implements MetricObserver {
}
protected static String normalizeAtlasUri(String uri) {
Matcher matcher = Pattern.compile("(.+?)(/api/v1/publish)?/?").matcher(uri);
matcher.matches();
return matcher.group(1) + "/api/v1/publish";
if (uri != null) {
Matcher matcher = Pattern.compile("(.+?)(/api/v1/publish)?/?").matcher(uri);
if (matcher.matches())
return matcher.group(1) + "/api/v1/publish";
else
throw new IllegalStateException("netflix.atlas.uri is not a valid uri");
}
throw new IllegalStateException("netflix.atlas.uri was not found in your properties and is required to communicate with Atlas");
}
@Override
......
......@@ -53,6 +53,16 @@ public class AtlasMetricObserverTests {
assertEquals(normalized, AtlasMetricObserver.normalizeAtlasUri("http://localhost:7001/api/v1/publish/"));
}
@Test(expected = IllegalStateException.class)
public void emptyAtlasUriThrowsException() {
AtlasMetricObserver.normalizeAtlasUri("");
}
@Test(expected = IllegalStateException.class)
public void missingAtlasUriThrowsException() {
AtlasMetricObserver.normalizeAtlasUri(null);
}
@Test
public void checkValidityOfTags() {
assertTrue(AtlasMetricObserver.validTags(BasicTagList.of("foo", "bar")));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment