-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Large files throw YAML exceptions #23617
Comments
Thanks for the sample. You aren't using any Spring Boot code to load the YAML so, unfortunately, there's nothing we can change here to help you. The problem is your Alternatively, you may want to move away from using |
Thanks for the suggestions, that seemed to work! For others looking to solve this, we overwrote public class UnlimitedYamlPropertiesFactoryBean extends YamlPropertiesFactoryBean {
@Override
protected Yaml createYaml() {
LoaderOptions loaderOptions = new LoaderOptions();
loaderOptions.setAllowDuplicateKeys(false);
loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE);
loaderOptions.setAllowRecursiveKeys(true);
return new Yaml(loaderOptions);
}
} Then referenced this new class from our overwritten public class YamlPropertySourceFactory implements PropertySourceFactory {
@SuppressWarnings({"NullableProblems", "ConstantConditions"})
@Override
public PropertySource<?> createPropertySource(String name, EncodedResource encodedResource) {
YamlPropertiesFactoryBean factory = new UnlimitedYamlPropertiesFactoryBean();
factory.setResources(encodedResource.getResource());
Properties properties = factory.getObject();
return new PropertiesPropertySource(encodedResource.getResource().getFilename(), properties);
}
} We then referenced that factory when loading our yaml into a configuration: @Configuration
@PropertySource(value = "classpath:pages-config.yaml", factory = YamlPropertySourceFactory.class)
@ConfigurationProperties(prefix = "shiba-configuration") |
Spring Boot Version:
2.3.4
Issue:
As referenced in #23096, trying to load our app (which uses quite a lot of big yaml files) still causes the following stack trace:
Downgrading the version of snakeyaml to 1.25 as suggested in the old issue fails as well since these functions in OriginTrackedYamlLoader no longer exist:
The branch of our app with this version is here.
For an example of how we use yaml, see this test (which is failing on 2.3.4), the class that's using the yaml, and the yaml the test is using.
The text was updated successfully, but these errors were encountered: