Skip to content

Commit

Permalink
Merge pull request #13194 from grails/5.3.x-snakeyaml
Browse files Browse the repository at this point in the history
Upgrade snakeyaml, micronaut, spring and spring boot
  • Loading branch information
puneetbehl authored Nov 4, 2023
2 parents bfc5715 + 0c86bf7 commit 4885006
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 15 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ methvinDirectoryWatcherVersion=0.18.0
micronautCacheVersion=3.5.0
micronautRuntimeGroovyVersion=3.0.0
micronautSpringVersion=4.5.0
micronautVersion=3.8.5
micronautVersion=3.8.8
mongodbJavaDriverVersion=4.5.0
objenesisVersion=3.3
scaffoldingCoreVersion=2.1.0
servletApiVersion=4.0.1
slf4jVersion=1.7.36
spockVersion=2.1-groovy-3.0
springBootVersion=2.7.9
springBootVersion=2.7.10
springLoadedVersion=1.2.8.RELEASE
springVersion=5.3.25
springVersion=5.3.26
testingSupportVersion=2.4.1
testingSupportVersionForTests=2.6.1
tomcatLog4jVersion=8.5.2
Expand Down
2 changes: 1 addition & 1 deletion grails-bootstrap/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
dependencies {
api ( "org.codehaus.groovy:groovy-xml:$groovyVersion" )
api ( "org.codehaus.groovy:groovy-templates:$groovyVersion" )
api "org.yaml:snakeyaml:1.33"
api "org.yaml:snakeyaml"
api "io.micronaut:micronaut-inject:$micronautVersion"

compileOnly("io.methvin:directory-watcher:$methvinDirectoryWatcherVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import org.codehaus.groovy.runtime.DefaultGroovyMethods
import org.codehaus.groovy.runtime.typehandling.GroovyCastException
import org.yaml.snakeyaml.LoaderOptions
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.constructor.SafeConstructor

Expand Down Expand Up @@ -154,7 +155,7 @@ class CodeGenConfig implements Cloneable, ConfigMap {

@CompileDynamic // fails with CompileStatic!
void loadYml(InputStream input) {
Yaml yaml = new Yaml(new SafeConstructor())
Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()))
for(Object yamlObject : yaml.loadAll(input)) {
if(yamlObject instanceof Map) { // problem here with CompileStatic
mergeMap((Map)yamlObject)
Expand Down
2 changes: 1 addition & 1 deletion grails-docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
"org.slf4j:jcl-over-slf4j:$slf4jVersion",
"org.apache.ant:ant:$antVersion",
'org.grails:grails-gdoc-engine:1.0.1',
'org.yaml:snakeyaml:1.33',
'org.yaml:snakeyaml:2.2',
"org.codehaus.groovy:groovy-ant:$groovyVersion"

api 'org.asciidoctor:asciidoctorj:2.5.7'
Expand Down
5 changes: 3 additions & 2 deletions grails-docs/src/main/groovy/grails/doc/DocPublisher.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory
import org.radeox.api.engine.WikiRenderEngine
import org.radeox.engine.context.BaseInitialRenderContext
import org.radeox.engine.context.BaseRenderContext
import org.yaml.snakeyaml.LoaderOptions
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.constructor.SafeConstructor

Expand Down Expand Up @@ -265,7 +266,7 @@ class DocPublisher {
def legacyLinks = [:]
if (legacyLinksFile.exists()) {
legacyLinksFile.withInputStream { input ->
legacyLinks = new Yaml(new SafeConstructor()).load(input)
legacyLinks = new Yaml(new SafeConstructor(new LoaderOptions())).load(input)
}
}

Expand Down Expand Up @@ -537,7 +538,7 @@ class DocPublisher {
}
else if(propertiesFile.name.endsWith('.yml')) {
propertiesFile.withInputStream { input ->
def ymls = new Yaml(new SafeConstructor()).loadAll(input)
def ymls = new Yaml(new SafeConstructor(new LoaderOptions())).loadAll(input)
for(yml in ymls) {
if(yml instanceof Map) {
def config = yml.grails?.doc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package grails.doc.internal

import org.yaml.snakeyaml.LoaderOptions
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.constructor.SafeConstructor

/**
* Class representing a Grails user guide table of contents defined in YAML.
*/
class YamlTocStrategy {
private final parser = new Yaml(new SafeConstructor())
private final parser = new Yaml(new SafeConstructor(new LoaderOptions()))
private resourceChecker
private String ext = ".gdoc"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import groovy.transform.CompileStatic
import groovy.transform.InheritConstructors
import org.gradle.tooling.ProjectConnection
import org.yaml.snakeyaml.DumperOptions
import org.yaml.snakeyaml.LoaderOptions
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.constructor.SafeConstructor
import org.yaml.snakeyaml.representer.Representer
Expand All @@ -37,7 +38,7 @@ abstract class MapReadingCachedGradleOperation <V> extends CachedGradleOperation
@Override
Map<String, V> readFromCached(File f) {
def map = (Map<String, Object>) f.withReader { BufferedReader r ->
new Yaml(new SafeConstructor()).load(r)
new Yaml(new SafeConstructor(new LoaderOptions())).load(r)
}
Map<String, V> newMap = [:]

Expand All @@ -61,7 +62,7 @@ abstract class MapReadingCachedGradleOperation <V> extends CachedGradleOperation
return [(key):val.toString()]
}
}
new Yaml(new SafeConstructor(), new Representer(), options).dump(toWrite, writer)
new Yaml(new SafeConstructor(new LoaderOptions()), new Representer(options), options).dump(toWrite, writer)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.grails.cli.profile.commands.DefaultMultiStepCommand
import org.grails.cli.profile.commands.script.GroovyScriptCommand
import org.grails.config.NavigableMap
import org.grails.io.support.Resource
import org.yaml.snakeyaml.LoaderOptions
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.constructor.SafeConstructor

Expand Down Expand Up @@ -110,7 +111,7 @@ abstract class AbstractProfile implements Profile {

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

name = profileConfig.get("name")?.toString()
description = profileConfig.get("description")?.toString() ?: ''
Expand Down Expand Up @@ -140,7 +141,7 @@ abstract class AbstractProfile implements Profile {
else if(fileName.endsWith('.yml')) {
def yamlCommand = profileDir.createRelative("commands/$fileName")
if(yamlCommand.exists()) {
Map<String, Object> data = new Yaml(new SafeConstructor()).<Map>load(yamlCommand.getInputStream())
Map<String, Object> data = new Yaml(new SafeConstructor(new LoaderOptions())).<Map>load(yamlCommand.getInputStream())
Command cmd = new DefaultMultiStepCommand(clsName.toString(), this, data)
Object minArguments = data?.minArguments
cmd.minArguments = minArguments instanceof Integer ? (Integer)minArguments : 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import groovy.transform.ToString
import org.eclipse.aether.graph.Dependency
import org.grails.config.NavigableMap
import org.grails.io.support.Resource
import org.yaml.snakeyaml.LoaderOptions
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.constructor.SafeConstructor

Expand Down Expand Up @@ -50,7 +51,7 @@ class DefaultFeature implements Feature {
this.name = name
this.location = location
def featureYml = location.createRelative("feature.yml")
Map<String, Object> featureConfig = new Yaml(new SafeConstructor()).<Map<String, Object>>load(featureYml.getInputStream())
Map<String, Object> featureConfig = new Yaml(new SafeConstructor(new LoaderOptions())).<Map<String, Object>>load(featureYml.getInputStream())
configuration.merge(featureConfig)
def dependenciesConfig = configuration.get("dependencies")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.grails.cli.profile.Command
import org.grails.cli.profile.Profile
import org.grails.cli.profile.commands.DefaultMultiStepCommand
import org.grails.io.support.Resource
import org.yaml.snakeyaml.LoaderOptions
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.constructor.SafeConstructor

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

Expand Down

0 comments on commit 4885006

Please sign in to comment.