Skip to content

Commit 96ac170

Browse files
authored
Update to SnakeYaml 2.0 (#12993)
* Revert "Downgrade to SnakeYaml 1.33 due incompatibility with Spring 5 (#12921)" This reverts commit 0a8e6c6. * Use Correct SafeConstructor
1 parent 35dd03d commit 96ac170

File tree

8 files changed

+16
-14
lines changed

8 files changed

+16
-14
lines changed

build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,6 @@ subprojects { project ->
311311
documentation
312312
}
313313

314-
configurations {
315-
all {
316-
/*Spring framework {@link org.springframework.beans.factory.config.*/
317-
resolutionStrategy.force 'org.yaml:snakeyaml:1.33'
318-
}
319-
}
320-
321314
ext.isTestSuite = project.name.startsWith("grails-test-suite")
322315
ext.isCiBuild = project.hasProperty("isCiBuild") || System.getenv().get("CI") as Boolean
323316
ext.pomInfo = {

grails-bootstrap/src/main/groovy/grails/util/GrailsNameUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ static String convertValidPropertyMethodSuffix(String suffix) {
627627
* @return true if it is a javabean property getter
628628
* @deprecated use {@link #isGetter(String, Class, Class[])} instead because this method has a defect for "is.." method with Boolean return types.
629629
*/
630+
@Deprecated
630631
public static boolean isGetter(String name, Class<?>[] args) {
631632
return isGetter(name, boolean.class, args);
632633
}

grails-bootstrap/src/main/groovy/org/grails/config/CodeGenConfig.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ import groovy.transform.CompileDynamic
2222
import groovy.transform.CompileStatic
2323
import org.codehaus.groovy.runtime.DefaultGroovyMethods
2424
import org.codehaus.groovy.runtime.typehandling.GroovyCastException
25+
import org.yaml.snakeyaml.DumperOptions
26+
import org.yaml.snakeyaml.LoaderOptions
2527
import org.yaml.snakeyaml.Yaml
2628
import org.yaml.snakeyaml.constructor.SafeConstructor
29+
import org.yaml.snakeyaml.representer.Representer
2730

2831

2932
/**
@@ -154,7 +157,7 @@ class CodeGenConfig implements Cloneable, ConfigMap {
154157

155158
@CompileDynamic // fails with CompileStatic!
156159
void loadYml(InputStream input) {
157-
Yaml yaml = new Yaml(new SafeConstructor())
160+
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()))
158161
for(Object yamlObject : yaml.loadAll(input)) {
159162
if(yamlObject instanceof Map) { // problem here with CompileStatic
160163
mergeMap((Map)yamlObject)

grails-shell/src/main/groovy/org/grails/cli/gradle/cache/MapReadingCachedGradleOperation.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import groovy.transform.CompileStatic
2020
import groovy.transform.InheritConstructors
2121
import org.gradle.tooling.ProjectConnection
2222
import org.yaml.snakeyaml.DumperOptions
23+
import org.yaml.snakeyaml.LoaderOptions
2324
import org.yaml.snakeyaml.Yaml
2425
import org.yaml.snakeyaml.constructor.SafeConstructor
2526
import org.yaml.snakeyaml.representer.Representer
@@ -37,7 +38,7 @@ abstract class MapReadingCachedGradleOperation <V> extends CachedGradleOperation
3738
@Override
3839
Map<String, V> readFromCached(File f) {
3940
def map = (Map<String, Object>) f.withReader { BufferedReader r ->
40-
new Yaml(new SafeConstructor()).load(r)
41+
new Yaml(new SafeConstructor(new LoaderOptions())).load(r)
4142
}
4243
Map<String, V> newMap = [:]
4344

@@ -61,7 +62,7 @@ abstract class MapReadingCachedGradleOperation <V> extends CachedGradleOperation
6162
return [(key):val.toString()]
6263
}
6364
}
64-
new Yaml(new SafeConstructor(), new Representer(), options).dump(toWrite, writer)
65+
new Yaml(new SafeConstructor(new LoaderOptions()), new Representer(options), options).dump(toWrite, writer)
6566
}
6667

6768
}

grails-shell/src/main/groovy/org/grails/cli/profile/AbstractProfile.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import org.grails.cli.profile.commands.DefaultMultiStepCommand
3333
import org.grails.cli.profile.commands.script.GroovyScriptCommand
3434
import org.grails.config.NavigableMap
3535
import org.grails.io.support.Resource
36+
import org.yaml.snakeyaml.LoaderOptions
3637
import org.yaml.snakeyaml.Yaml
3738
import org.yaml.snakeyaml.constructor.SafeConstructor
3839

@@ -110,7 +111,7 @@ abstract class AbstractProfile implements Profile {
110111

111112
protected void initialize() {
112113
def profileYml = profileDir.createRelative("profile.yml")
113-
Map<String, Object> profileConfig = new Yaml(new SafeConstructor()).<Map<String, Object>> load(profileYml.getInputStream())
114+
Map<String, Object> profileConfig = new Yaml(new SafeConstructor(new LoaderOptions())).<Map<String, Object>> load(profileYml.getInputStream())
114115

115116
name = profileConfig.get("name")?.toString()
116117
description = profileConfig.get("description")?.toString() ?: ''
@@ -140,7 +141,7 @@ abstract class AbstractProfile implements Profile {
140141
else if(fileName.endsWith('.yml')) {
141142
def yamlCommand = profileDir.createRelative("commands/$fileName")
142143
if(yamlCommand.exists()) {
143-
Map<String, Object> data = new Yaml(new SafeConstructor()).<Map>load(yamlCommand.getInputStream())
144+
Map<String, Object> data = new Yaml(new SafeConstructor(new LoaderOptions())).<Map>load(yamlCommand.getInputStream())
144145
Command cmd = new DefaultMultiStepCommand(clsName.toString(), this, data)
145146
Object minArguments = data?.minArguments
146147
cmd.minArguments = minArguments instanceof Integer ? (Integer)minArguments : 1

grails-shell/src/main/groovy/org/grails/cli/profile/DefaultFeature.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import groovy.transform.ToString
2222
import org.eclipse.aether.graph.Dependency
2323
import org.grails.config.NavigableMap
2424
import org.grails.io.support.Resource
25+
import org.yaml.snakeyaml.LoaderOptions
2526
import org.yaml.snakeyaml.Yaml
2627
import org.yaml.snakeyaml.constructor.SafeConstructor
2728

@@ -50,7 +51,7 @@ class DefaultFeature implements Feature {
5051
this.name = name
5152
this.location = location
5253
def featureYml = location.createRelative("feature.yml")
53-
Map<String, Object> featureConfig = new Yaml(new SafeConstructor()).<Map<String, Object>>load(featureYml.getInputStream())
54+
Map<String, Object> featureConfig = new Yaml(new SafeConstructor(new LoaderOptions())).<Map<String, Object>>load(featureYml.getInputStream())
5455
configuration.merge(featureConfig)
5556
def dependenciesConfig = configuration.get("dependencies")
5657

grails-shell/src/main/groovy/org/grails/cli/profile/commands/factory/YamlCommandFactory.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.grails.cli.profile.Command
2222
import org.grails.cli.profile.Profile
2323
import org.grails.cli.profile.commands.DefaultMultiStepCommand
2424
import org.grails.io.support.Resource
25+
import org.yaml.snakeyaml.LoaderOptions
2526
import org.yaml.snakeyaml.Yaml
2627
import org.yaml.snakeyaml.constructor.SafeConstructor
2728

@@ -36,7 +37,7 @@ import java.util.regex.Pattern
3637
*/
3738
@CompileStatic
3839
class YamlCommandFactory extends ResourceResolvingCommandFactory<Map> {
39-
protected Yaml yamlParser=new Yaml(new SafeConstructor())
40+
protected Yaml yamlParser=new Yaml(new SafeConstructor(new LoaderOptions()))
4041
// LAX parser for JSON: http://mrhaki.blogspot.ie/2014/08/groovy-goodness-relax-groovy-will-parse.html
4142
protected JsonSlurper jsonSlurper = new JsonSlurper().setType(JsonParserType.LAX)
4243

grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ public static View resolveView(HttpServletRequest request, String viewName, Stri
197197
/**
198198
* @deprecated Does not take into account the url converter
199199
*/
200+
@Deprecated
200201
public static String addViewPrefix(String viewName) {
201202
GrailsWebRequest webRequest = GrailsWebRequest.lookup();
202203
return addViewPrefix(viewName, webRequest != null ? webRequest.getControllerName() : null);

0 commit comments

Comments
 (0)