From b5587b053debb07e1dc2f8ae96a0abea4e723780 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 20 Jul 2021 16:53:07 +0100 Subject: [PATCH] Use ClassLoader that will load Yaml to check if it's present Fixes gh-27133 --- .../springframework/boot/env/YamlPropertySourceLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java index a9eeafbf4e..f3a2c4b3cb 100755 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public class YamlPropertySourceLoader implements PropertySourceLoader { @Override public List> load(String name, Resource resource) throws IOException { - if (!ClassUtils.isPresent("org.yaml.snakeyaml.Yaml", null)) { + if (!ClassUtils.isPresent("org.yaml.snakeyaml.Yaml", getClass().getClassLoader())) { throw new IllegalStateException( "Attempted to load " + name + " but snakeyaml was not found on the classpath"); }