Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions grails-test-examples/issue-10279/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
plugins {
id 'org.apache.grails.buildsrc.properties'
id 'org.apache.grails.buildsrc.dependency-validator'
id 'org.apache.grails.buildsrc.compile'
}

version = '0.1'
group = 'issue10279'

apply plugin: 'org.apache.grails.gradle.grails-web'

dependencies {
implementation platform(project(':grails-bom'))

implementation 'org.springframework.boot:spring-boot-starter-logging'
implementation 'org.apache.grails:grails-dependencies-starter-web'

testAndDevelopmentOnly platform(project(':grails-bom'))

testImplementation 'org.apache.grails:grails-testing-support-web'
testImplementation 'org.spockframework:spock-core'

integrationTestImplementation 'com.fasterxml.jackson.core:jackson-databind'
integrationTestImplementation project(':grails-testing-support-http-client')
}

apply {
from rootProject.layout.projectDirectory.file('gradle/functional-test-config.gradle')
from rootProject.layout.projectDirectory.file('gradle/grails-extension-gradle-config.gradle')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Reproduces issue #10279: defining a closure in application.groovy causes
// Jackson serialization failures when the Spring Boot Actuator /actuator/env
// endpoint is accessed.
grails.gorm.default.mapping = {
cache true
version false
}

grails.normal.string.property = 'hello-from-groovy-config'
44 changes: 44 additions & 0 deletions grails-test-examples/issue-10279/grails-app/conf/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

info:
app:
name: '@info.app.name@'
version: '@info.app.version@'
grailsVersion: '@info.app.grailsVersion@'

grails:
profile: web
codegen:
defaultPackage: issue10279
mime:
types:
all: '*/*'
json:
- application/json
- text/json
xml:
- text/xml
- application/xml

# Expose the /actuator/env endpoint so the functional test can hit it.
management:
endpoints:
web:
exposure:
include: 'env,health'
endpoint:
env:
show-values: always
39 changes: 39 additions & 0 deletions grails-test-examples/issue-10279/grails-app/conf/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
<configuration>

<conversionRule conversionWord="clr" class="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" class="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>true</withJansi>
<encoder>
<charset>UTF-8</charset>
<pattern>%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex</pattern>
</encoder>
</appender>

<root level="info">
<appender-ref ref="STDOUT" />
</root>

</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package issue10279

class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.$format)?" {
constraints {}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package issue10279

import grails.boot.GrailsApp
import grails.boot.config.GrailsAutoConfiguration
import groovy.transform.CompileStatic

@CompileStatic
class Application extends GrailsAutoConfiguration {
static void main(String[] args) {
GrailsApp.run(Application, args)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package issue10279

import spock.lang.Specification
import spock.lang.Tag

import grails.testing.mixin.integration.Integration
import org.apache.grails.testing.http.client.HttpClientSupport

/**
* Regression test for GitHub issue #10279.
*
* When application.groovy defines closure-valued properties (e.g. grails.gorm.default.mapping),
* the Spring Boot Actuator /actuator/env endpoint must not throw a Jackson serialization error.
*
* In Grails 3.x this caused a JsonMappingException because the Closure held a delegate chain
* that referenced GroovyClassLoader internals, which Jackson could not serialize.
*/
@Integration
@Tag('http-client')
class ActuatorEnvClosureSpec extends Specification implements HttpClientSupport {

void 'actuator /env endpoint returns 200 when application.groovy contains closure-valued config'() {
when: 'the actuator environment endpoint is accessed'
def response = http('/actuator/env')

then: 'it responds successfully without a Jackson serialization error (issue #10279)'
response.assertStatus(200)
}

void 'actuator /env endpoint response contains normal string properties from application.groovy'() {
when: 'the actuator environment endpoint is accessed'
def response = http('/actuator/env')

then: 'it responds successfully'
response.assertStatus(200)

and: 'the string property defined in application.groovy is present in the response'
response.assertContains('hello-from-groovy-config')
}
}
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ include(
'grails-test-examples-plugins-issue11005',
'grails-test-examples-issue-11767',
'grails-test-examples-issue-15228',
'grails-test-examples-issue-10279',
'grails-test-examples-plugins-exploded',
'grails-test-examples-plugins-issue-11767',
'grails-test-examples-plugins-micronaut-singleton',
Expand Down Expand Up @@ -439,6 +440,7 @@ project(':grails-test-examples-plugins-loadafter').projectDir = file('grails-tes
project(':grails-test-examples-plugins-issue11005').projectDir = file('grails-test-examples/plugins/issue11005')
project(':grails-test-examples-issue-11767').projectDir = file('grails-test-examples/issue-11767')
project(':grails-test-examples-issue-15228').projectDir = file('grails-test-examples/issue-15228')
project(':grails-test-examples-issue-10279').projectDir = file('grails-test-examples/issue-10279')
project(':grails-test-examples-plugins-exploded').projectDir = file('grails-test-examples/plugins/exploded')
project(':grails-test-examples-plugins-issue-11767').projectDir = file('grails-test-examples/plugins/issue-11767')
project(':grails-test-examples-plugins-micronaut-singleton').projectDir = file('grails-test-examples/plugins/micronaut-singleton')
Expand Down
Loading