Skip to content

Commit 9094b2d

Browse files
committed
Merge remote-tracking branch 'origin/5.4.x' into 6.2.x
2 parents d4ecf70 + 195edeb commit 9094b2d

File tree

4 files changed

+48
-7
lines changed

4 files changed

+48
-7
lines changed

.github/workflows/groovy-joint-workflow.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
groovyVersion: ${{ steps.groovy-version.outputs.value }}
3939
steps:
4040
- name: Set up JDK
41-
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4
41+
uses: actions/setup-java@v4
4242
with:
4343
distribution: 'adopt'
4444
java-version: '11.0.6'
@@ -52,11 +52,8 @@ jobs:
5252
restore-keys: |
5353
${{ runner.os }}-maven-
5454
- name: Checkout Groovy 3_0_X (Grails 5 and later)
55+
if: startsWith('refs/head/6.', github.ref) || startsWith('6.', github.base_ref) || startsWith('refs/head/5.', github.ref) || startsWith('5.', github.base_ref)
5556
run: cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_3_0_X --single-branch
56-
if: github.ref == 'refs/heads/6.2.x' || github.base_ref == '6.2.x' || github.ref == 'refs/heads/6.1.x' || github.base_ref == '6.1.x' || github.ref == 'refs/heads/6.0.x' || github.base_ref == '6.0.x' || github.ref == 'refs/heads/5.3.x' || github.base_ref == '5.3.x' || github.ref == 'refs/heads/5.2.x' || github.base_ref == '5.2.x' || github.ref == 'refs/heads/5.1.x' || github.base_ref == '5.1.x' || github.ref == 'refs/heads/5.0.x' || github.base_ref == '5.0.x' || github.ref == 'refs/heads/master' || github.base_ref == 'master'
57-
- name: Checkout Groovy 2_5_X (Grails 4.0.x)
58-
run: cd .. && git clone --depth 1 https://github.com/grails/grails-core.git -b GROOVY_2_5_X --single-branch
59-
if: github.ref == 'refs/heads/4.1.x' || github.base_ref == '4.1.x' || github.ref == 'refs/heads/4.0.x' || github.base_ref == '4.0.x'
6057
- name: Set CI_GROOVY_VERSION for Grails
6158
id: groovy-version
6259
run: |
@@ -130,7 +127,7 @@ jobs:
130127
steps:
131128
- uses: actions/checkout@v4
132129
- name: Set up JDK
133-
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4
130+
uses: actions/setup-java@v4
134131
with:
135132
distribution: 'adopt'
136133
java-version: '11'

grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/DefaultUrlMappingEvaluator.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,9 @@ private UrlMapping getURLMappingForNamedArgs(Map namedArguments,
11301130
UrlMapping urlMapping;
11311131
if (uri != null) {
11321132
try {
1133-
urlMapping = new RegexUrlMapping(urlData, new URI(uri.toString()), constraints, grailsApplication);
1133+
urlMapping = isResponseCode ?
1134+
new ResponseCodeUrlMapping(urlData, new URI(uri.toString()), constraints, grailsApplication) :
1135+
new RegexUrlMapping(urlData, new URI(uri.toString()), constraints, grailsApplication);
11341136
} catch (URISyntaxException e) {
11351137
throw new UrlMappingException("Cannot map to invalid URI: " + e.getMessage(), e);
11361138
}

grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/ResponseCodeUrlMapping.java

+9
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import grails.gorm.validation.ConstrainedProperty;
2020
import grails.web.mapping.UrlMappingData;
2121
import grails.web.mapping.UrlMappingInfo;
22+
import java.net.URI;
2223
import org.springframework.util.Assert;
2324

2425
import java.util.Collections;
@@ -46,6 +47,14 @@ public ResponseCodeUrlMapping(UrlMappingData urlData, Object controllerName, Obj
4647
"Constraints can't be used for response code url mapping");
4748
}
4849

50+
public ResponseCodeUrlMapping(UrlMappingData urlData, URI uri, ConstrainedProperty[] constraints, GrailsApplication grailsApplication) {
51+
super(uri, constraints, grailsApplication);
52+
this.urlData = (ResponseCodeMappingData) urlData;
53+
54+
Assert.isTrue(constraints == null || constraints.length == 0,
55+
"Constraints can't be used for response code url mapping");
56+
}
57+
4958
public UrlMappingInfo match(String uri) {
5059
return null;
5160
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package org.grails.web.mapping
2+
3+
import grails.web.mapping.UrlMapping
4+
import spock.lang.Specification
5+
6+
class DefaultUrlMappingEvaluatorSpec extends Specification {
7+
8+
void "test evaluate mapping: #logicalUrls to view: #viewName, controller: #controllerName, action: #actionName, uri: #forwardURI as #clazz.simpleName"() {
9+
given:
10+
DefaultUrlMappingEvaluator defaultUrlMappingEvaluator = new DefaultUrlMappingEvaluator(null)
11+
12+
when:
13+
List<UrlMapping> mappings = defaultUrlMappingEvaluator.evaluateMappings closure
14+
15+
then:
16+
mappings.size() == 1
17+
mappings[0].urlData.logicalUrls == logicalUrls
18+
mappings[0].class == clazz
19+
mappings[0].viewName == viewName
20+
mappings[0].controllerName == controllerName
21+
mappings[0].actionName == actionName
22+
mappings[0].forwardURI == forwardURI
23+
24+
where:
25+
closure | logicalUrls | viewName | controllerName | actionName | forwardURI | clazz
26+
({ '/lorem/ipsum'(view: '/foobar') }) | ['/lorem/ipsum'] | '/foobar' | null | null | null | RegexUrlMapping.class
27+
({ '/lorem/ipsum'(controller: 'foo', action: 'bar') }) | ['/lorem/ipsum'] | null | 'foo' | 'bar' | null | RegexUrlMapping.class
28+
({ '/lorem/ipsum'(uri: '/foo/bar') }) | ['/lorem/ipsum'] | null | null | null | new URI('/foo/bar') | RegexUrlMapping.class
29+
({ '404'(view: '/foobar') }) | ['404'] | '/foobar' | null | null | null | ResponseCodeUrlMapping.class
30+
({ '404'(controller: 'foo', action: 'bar') }) | ['404'] | null | 'foo' | 'bar' | null | ResponseCodeUrlMapping.class
31+
({ '404'(uri: '/foo/bar') }) | ['404'] | null | null | null | new URI('/foo/bar') | ResponseCodeUrlMapping.class
32+
}
33+
}

0 commit comments

Comments
 (0)