Spring boot service name (#8006)
resolves #7998 --------- Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com> Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
This commit is contained in:
parent
5a0e2cb765
commit
d6271cccc7
|
@ -178,7 +178,8 @@ public class SpringBootServiceNameDetector implements ConditionalResourceProvide
|
||||||
try {
|
try {
|
||||||
LoadSettings settings = LoadSettings.builder().build();
|
LoadSettings settings = LoadSettings.builder().build();
|
||||||
Load yaml = new Load(settings);
|
Load yaml = new Load(settings);
|
||||||
Map<String, Object> data = (Map<String, Object>) yaml.loadFromInputStream(in);
|
for (Object o : yaml.loadAllFromInputStream(in)) {
|
||||||
|
Map<String, Object> data = (Map<String, Object>) o;
|
||||||
Map<String, Map<String, Object>> spring =
|
Map<String, Map<String, Object>> spring =
|
||||||
(Map<String, Map<String, Object>>) data.get("spring");
|
(Map<String, Map<String, Object>>) data.get("spring");
|
||||||
if (spring != null) {
|
if (spring != null) {
|
||||||
|
@ -188,6 +189,7 @@ public class SpringBootServiceNameDetector implements ConditionalResourceProvide
|
||||||
return (String) name;
|
return (String) name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
// expected to fail sometimes
|
// expected to fail sometimes
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,16 @@ class SpringBootServiceNameDetectorTest {
|
||||||
expectServiceName(result, "cat-store");
|
expectServiceName(result, "cat-store");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void classpathApplicationYamlContainingMultipleYamlDefinitions() {
|
||||||
|
when(system.openClasspathResource(APPLICATION_YML))
|
||||||
|
.thenReturn(
|
||||||
|
ClassLoader.getSystemClassLoader().getResourceAsStream("application-multi.yml"));
|
||||||
|
SpringBootServiceNameDetector guesser = new SpringBootServiceNameDetector(system);
|
||||||
|
Resource result = guesser.createResource(config);
|
||||||
|
expectServiceName(result, "cat-store");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void yamlFileInCurrentDir() throws Exception {
|
void yamlFileInCurrentDir() throws Exception {
|
||||||
Path yamlPath = Paths.get(APPLICATION_YML);
|
Path yamlPath = Paths.get(APPLICATION_YML);
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
flib:
|
||||||
|
something:
|
||||||
|
12
|
||||||
|
|
||||||
|
section:
|
||||||
|
two: 2
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 777
|
||||||
|
context-path: /meow
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: cat-store
|
||||||
|
|
||||||
|
---
|
||||||
|
some:
|
||||||
|
other:
|
||||||
|
property: value
|
Loading…
Reference in New Issue