File tree 2 files changed +7
-2
lines changed
spring-boot-project/spring-boot/src
main/java/org/springframework/boot/json
test/java/org/springframework/boot/json
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 26
26
import org .yaml .snakeyaml .Yaml ;
27
27
import org .yaml .snakeyaml .constructor .Constructor ;
28
28
29
+ import org .springframework .util .Assert ;
30
+
29
31
/**
30
32
* Thin wrapper to adapt Snake {@link Yaml} to {@link JsonParser}.
31
33
*
@@ -63,7 +65,9 @@ private static class TypeLimitedConstructor extends Constructor {
63
65
64
66
@ Override
65
67
protected Class <?> getClassForName (String name ) throws ClassNotFoundException {
66
- return (SUPPORTED_TYPES .contains (name )) ? super .getClassForName (name ) : null ;
68
+ Assert .state (SUPPORTED_TYPES .contains (name ),
69
+ () -> "Unsupported '" + name + "' type encountered in YAML document" );
70
+ return super .getClassForName (name );
67
71
}
68
72
69
73
}
Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ protected JsonParser getParser() {
36
36
@ Test
37
37
public void customTypesAreNotLoaded () throws Exception {
38
38
assertThatExceptionOfType (ConstructorException .class )
39
- .isThrownBy (() -> getParser ().parseMap ("{value: !!java.net.URL [\" http://localhost:9000/\" ]}" ));
39
+ .isThrownBy (() -> getParser ().parseMap ("{value: !!java.net.URL [\" http://localhost:9000/\" ]}" ))
40
+ .withCauseInstanceOf (IllegalStateException .class );
40
41
}
41
42
42
43
}
You can’t perform that action at this time.
0 commit comments