|
|
@ -45,6 +45,7 @@ import org.springframework.boot.origin.OriginTrackedValue;
|
|
|
|
import org.springframework.boot.origin.TextResourceOrigin;
|
|
|
|
import org.springframework.boot.origin.TextResourceOrigin;
|
|
|
|
import org.springframework.boot.origin.TextResourceOrigin.Location;
|
|
|
|
import org.springframework.boot.origin.TextResourceOrigin.Location;
|
|
|
|
import org.springframework.core.io.Resource;
|
|
|
|
import org.springframework.core.io.Resource;
|
|
|
|
|
|
|
|
import org.springframework.util.ReflectionUtils;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Class to load {@code .yml} files into a map of {@code String} to
|
|
|
|
* Class to load {@code .yml} files into a map of {@code String} to
|
|
|
@ -55,6 +56,9 @@ import org.springframework.core.io.Resource;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class OriginTrackedYamlLoader extends YamlProcessor {
|
|
|
|
class OriginTrackedYamlLoader extends YamlProcessor {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final boolean HAS_RESOLVER_LIMIT = ReflectionUtils.findMethod(Resolver.class, "addImplicitResolver",
|
|
|
|
|
|
|
|
Tag.class, Pattern.class, String.class, int.class) != null;
|
|
|
|
|
|
|
|
|
|
|
|
private final Resource resource;
|
|
|
|
private final Resource resource;
|
|
|
|
|
|
|
|
|
|
|
|
OriginTrackedYamlLoader(Resource resource) {
|
|
|
|
OriginTrackedYamlLoader(Resource resource) {
|
|
|
@ -75,7 +79,7 @@ class OriginTrackedYamlLoader extends YamlProcessor {
|
|
|
|
BaseConstructor constructor = new OriginTrackingConstructor(loaderOptions);
|
|
|
|
BaseConstructor constructor = new OriginTrackingConstructor(loaderOptions);
|
|
|
|
Representer representer = new Representer();
|
|
|
|
Representer representer = new Representer();
|
|
|
|
DumperOptions dumperOptions = new DumperOptions();
|
|
|
|
DumperOptions dumperOptions = new DumperOptions();
|
|
|
|
LimitedResolver resolver = new LimitedResolver();
|
|
|
|
Resolver resolver = HAS_RESOLVER_LIMIT ? new NoTimestampResolverWithLimit() : new NoTimestampResolver();
|
|
|
|
return new Yaml(constructor, representer, dumperOptions, loaderOptions, resolver);
|
|
|
|
return new Yaml(constructor, representer, dumperOptions, loaderOptions, resolver);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -167,7 +171,7 @@ class OriginTrackedYamlLoader extends YamlProcessor {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* {@link Resolver} that limits {@link Tag#TIMESTAMP} tags.
|
|
|
|
* {@link Resolver} that limits {@link Tag#TIMESTAMP} tags.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private static class LimitedResolver extends Resolver {
|
|
|
|
private static class NoTimestampResolver extends Resolver {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
|
|
|
|
public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
|
|
|
@ -179,4 +183,19 @@ class OriginTrackedYamlLoader extends YamlProcessor {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* {@link Resolver} that limits {@link Tag#TIMESTAMP} tags.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private static class NoTimestampResolverWithLimit extends Resolver {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void addImplicitResolver(Tag tag, Pattern regexp, String first, int limit) {
|
|
|
|
|
|
|
|
if (tag == Tag.TIMESTAMP) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
super.addImplicitResolver(tag, regexp, first, limit);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|