Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
b5fe3c34
Commit
b5fe3c34
authored
Jun 03, 2020
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine YAML type restriction error
Closes gh-21596
parent
95031295
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
YamlJsonParser.java
...in/java/org/springframework/boot/json/YamlJsonParser.java
+5
-1
YamlJsonParserTests.java
...va/org/springframework/boot/json/YamlJsonParserTests.java
+2
-1
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/YamlJsonParser.java
View file @
b5fe3c34
...
...
@@ -26,6 +26,8 @@ import java.util.stream.Collectors;
import
org.yaml.snakeyaml.Yaml
;
import
org.yaml.snakeyaml.constructor.Constructor
;
import
org.springframework.util.Assert
;
/**
* Thin wrapper to adapt Snake {@link Yaml} to {@link JsonParser}.
*
...
...
@@ -63,7 +65,9 @@ public class YamlJsonParser extends AbstractJsonParser {
@Override
protected
Class
<?>
getClassForName
(
String
name
)
throws
ClassNotFoundException
{
return
(
SUPPORTED_TYPES
.
contains
(
name
))
?
super
.
getClassForName
(
name
)
:
null
;
Assert
.
state
(
SUPPORTED_TYPES
.
contains
(
name
),
()
->
"Unsupported '"
+
name
+
"' type encountered in YAML document"
);
return
super
.
getClassForName
(
name
);
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/json/YamlJsonParserTests.java
View file @
b5fe3c34
...
...
@@ -36,7 +36,8 @@ public class YamlJsonParserTests extends AbstractJsonParserTests {
@Test
public
void
customTypesAreNotLoaded
()
throws
Exception
{
assertThatExceptionOfType
(
ConstructorException
.
class
)
.
isThrownBy
(()
->
getParser
().
parseMap
(
"{value: !!java.net.URL [\"http://localhost:9000/\"]}"
));
.
isThrownBy
(()
->
getParser
().
parseMap
(
"{value: !!java.net.URL [\"http://localhost:9000/\"]}"
))
.
withCauseInstanceOf
(
IllegalStateException
.
class
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment