-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Make use of custom types configurable in YamlProcessor #25152
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Milestone
Comments
sbrannen
added a commit
that referenced
this issue
May 29, 2020
Prior to this commit, there was no easy way to restrict what types could be loaded from a YAML document in subclasses of YamlProcessor such as YamlPropertiesFactoryBean and YamlMapFactoryBean. This commit introduces a setSupportedTypes(Class<?>...) method in YamlProcessor in order to address this. If no supported types are configured, all types encountered in YAML documents will be supported. If an unsupported type is encountered, an IllegalStateException will be thrown when the corresponding YAML node is processed. Closes gh-25152
FelixFly
pushed a commit
to FelixFly/spring-framework
that referenced
this issue
Aug 16, 2020
Prior to this commit, there was no easy way to restrict what types could be loaded from a YAML document in subclasses of YamlProcessor such as YamlPropertiesFactoryBean and YamlMapFactoryBean. This commit introduces a setSupportedTypes(Class<?>...) method in YamlProcessor in order to address this. If no supported types are configured, all types encountered in YAML documents will be supported. If an unsupported type is encountered, an IllegalStateException will be thrown when the corresponding YAML node is processed. Closes spring-projectsgh-25152
bclozel
added a commit
that referenced
this issue
Feb 9, 2021
`spring-beans` ships a `YamlProcessor` that's used as a base class by `YamlMapFactoryBean` and `YamlPropertiesFactoryBean`. These implementations have a clear use case: mapping application-internal Yaml documents for configuration or infrastructure purposes. Since this use case rarely requires extended types support from the underlying library, and since we're offering ways to list custom types (since #25152), we'll restrict to java standard types only by default. This simplifies the setup and focuses the abstract class on the core use cases. Closes gh-26530
zx20110729
pushed a commit
to zx20110729/spring-framework
that referenced
this issue
Feb 18, 2022
Prior to this commit, there was no easy way to restrict what types could be loaded from a YAML document in subclasses of YamlProcessor such as YamlPropertiesFactoryBean and YamlMapFactoryBean. This commit introduces a setSupportedTypes(Class<?>...) method in YamlProcessor in order to address this. If no supported types are configured, all types encountered in YAML documents will be supported. If an unsupported type is encountered, an IllegalStateException will be thrown when the corresponding YAML node is processed. Closes spring-projectsgh-25152
I would like to know purpose of this PR. I see that Spring Boot defines |
ashimagarg67
pushed a commit
to ashimagarg67/spring-framework
that referenced
this issue
Apr 23, 2024
This PR replace snakeyaml with snakeyaml-engine in order to support YAML 1.2 Version 1.2 solves among others Norway problem https://hitchdev.com/strictyaml/why/implicit-typing-removed, mentioned in spring-projects/spring-boot#17113 The following compares versions 1.1 and 1.2: https://yaml.readthedocs.io/en/latest/pyyaml.html I drop off 'supportedTypes' support. The feature was add in spring-projects/spring-framework#25152. I asked question for purpose, but I didn't get answer. I decide to drop because: 1. Supported types are not directly provided by snakeyaml-engine 2. Clients - for example Spring Boot OriginTrackedYamlLoader - still may modify yaml setup 3. Supported types are not documented 4. I think that supported types is wrong idea. Parsing YAML should be simple and conversion may be implemented in application code.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Overview
Since SnakeYaml allows for custom types to be loaded when they are specified inside the YAML document, we should make it possible to configure the types that can be constructed.
Proposal
Provide a mechanism in
YamlProcessor
for configuring the supported custom types for theYaml
instance created inorg.springframework.beans.factory.config.YamlProcessor.createYaml()
.For example, a new
void setSupportedCustomTypes(Class<?>... types)
method could be added toYamlProcessor
. If no supported types are configured, theYaml
instance would be created as it is currently, without any restrictions. If supported types have been configured, theYaml
instance would be created with restrictions in place. TheTypeLimitedConstructor
recently introduced in Spring Boot can serve as inspiration for the latter.Related Issues
The text was updated successfully, but these errors were encountered: