Skip to content

Commit 2b589e0

Browse files
committed
Merge branch '3.1.x' into 3.2.x
2 parents 6671893 + 841f4df commit 2b589e0

File tree

7 files changed

+76
-20
lines changed

7 files changed

+76
-20
lines changed

grails-async/src/main/groovy/grails/async/Promises.groovy

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package grails.async;
16+
package grails.async
1717

18+
import grails.async.decorator.PromiseDecorator
19+
import groovy.transform.CompileStatic
20+
import org.grails.async.factory.SynchronousPromiseFactory
21+
import org.grails.async.factory.gpars.GparsPromiseFactory
1822

19-
import groovy.lang.Closure
20-
import groovy.transform.CompileStatic;
21-
22-
import java.util.List;
23-
import java.util.Map;
24-
import java.util.concurrent.TimeUnit;
25-
26-
import grails.async.decorator.PromiseDecorator;
27-
import org.grails.async.factory.SynchronousPromiseFactory;
28-
import org.grails.async.factory.gpars.GparsPromiseFactory;
29-
import org.grails.async.factory.reactor.ReactorPromiseFactory;
23+
import java.util.concurrent.TimeUnit
3024

3125
/**
3226
* Factory class for working with {@link Promise} instances

grails-async/src/main/groovy/org/grails/async/factory/reactor/ReactorPromise.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ import java.util.concurrent.TimeoutException
3131
*
3232
* @author Graeme Rocher
3333
* @since 3.0
34+
*
35+
* @deprecated Reactor promise integration is deprecated and will be removed in a future version of Grails
3436
*/
3537
@CompileStatic
38+
@Deprecated
3639
class ReactorPromise<T> implements Promise<T> {
3740

3841
reactor.rx.Promise<T> internalPromise

grails-async/src/main/groovy/org/grails/async/factory/reactor/ReactorPromiseFactory.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ import java.util.concurrent.TimeUnit
3131
*
3232
* @author Graeme Rocher
3333
* @since 3.0
34+
*
35+
* @deprecated Reactor promise integration is deprecated and will be removed in a future version of Grails
3436
*/
3537
@CompileStatic
38+
@Deprecated
3639
class ReactorPromiseFactory extends AbstractPromiseFactory {
3740
static final boolean REACTOR_PRESENT
3841
static {

grails-plugin-async/src/main/groovy/org/grails/plugins/web/async/ControllersAsyncGrailsPlugin.groovy

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,11 @@ class ControllersAsyncGrailsPlugin extends Plugin {
3535

3636
Closure doWithSpring() {{->
3737
asyncPromiseResponseActionResultTransformer(AsyncActionResultTransformer)
38-
3938
}}
4039

4140
@Override
4241
@CompileStatic
4342
void doWithDynamicMethods() {
44-
try {
45-
Promises.promiseFactory = new ReactorPromiseFactory(applicationContext.getBean(Environment))
46-
} catch (NoSuchBeanDefinitionException e) {
47-
// Reactor not configured
48-
}
4943
Promises.promiseFactory.addPromiseDecoratorLookupStrategy(new WebRequestPromiseDecoratorLookupStrategy())
5044
}
5145

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,12 +775,13 @@ private String establishFullURI(String uri, List<ConstrainedProperty> constraine
775775

776776
if(!isInCollection) {
777777
uriBuilder.append(SLASH).append(CAPTURING_WILD_CARD);
778-
constrainedList.add(new ConstrainedProperty(UrlMapping.class, parentResource.controllerName + "Id", String.class));
779778
}
780779
}
781780
}
782781

783-
uriBuilder.append(uri);
782+
if(!SLASH.equals(uri)) {
783+
uriBuilder.append(uri);
784+
}
784785
return uriBuilder.toString();
785786
}
786787

@@ -1197,6 +1198,12 @@ protected MetaMappingInfo pushNewMetaMappingInfo() {
11971198
if (parentMappingConstraints != null) {
11981199
mappingInfo.getConstraints().addAll(parentMappingConstraints);
11991200
}
1201+
ParentResource parentResource = parentResources.peek();
1202+
if(parentResource != null && !parentResource.isSingle) {
1203+
if(!isInCollection) {
1204+
mappingInfo.getConstraints().add(new ConstrainedProperty(UrlMapping.class, parentResource.controllerName + "Id", String.class));
1205+
}
1206+
}
12001207
}
12011208
if (previousConstraints.size() > 0) {
12021209
mappingInfo.getConstraints().addAll(previousConstraints);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.grails.web.mapping
2+
3+
import org.codehaus.groovy.grails.web.mapping.AbstractUrlMappingsSpec
4+
import spock.lang.Issue
5+
6+
/**
7+
* Created by graemerocher on 25/10/16.
8+
*/
9+
class NestedMappingWithinGroupSpec extends AbstractUrlMappingsSpec {
10+
11+
@Issue('https://github.com/grails/grails-core/issues/10246')
12+
void "test nested mapping within group"() {
13+
given:"A link generator with nested mappings withihn a group"
14+
def linkGenerator = getLinkGenerator {
15+
group("/api") {
16+
"/customer-stores"(resources: 'store') {
17+
"/catalogs"(controller: 'catalog', action: 'index', method: 'GET')
18+
"/catalogs/$catalogId/items"(controller: 'catalog', action: 'getItems', method: 'GET')
19+
}
20+
}
21+
}
22+
23+
expect:"The generated links to be correct"
24+
linkGenerator.link(controller:"catalog", action:"index", method:"GET", params:[storeId:'1']) == 'http://localhost/api/customer-stores/1/catalogs'
25+
linkGenerator.link(controller:"catalog", action:"getItems", method:"GET", params:[storeId:'1', catalogId:'2']) == 'http://localhost/api/customer-stores/1/catalogs/2/items'
26+
}
27+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.grails.web.mapping
2+
3+
import grails.web.mapping.LinkGenerator
4+
import org.codehaus.groovy.grails.web.mapping.AbstractUrlMappingsSpec
5+
import spock.lang.Issue
6+
7+
/**
8+
* Created by graemerocher on 25/10/16.
9+
*/
10+
class ResourcesWithSingleSlashSpec extends AbstractUrlMappingsSpec {
11+
12+
@Issue('https://github.com/grails/grails-core/issues/10210')
13+
void "test that resources expressed with a single slash product the correct URI"() {
14+
given:"url mappings within groups with resources expressed with a single slash"
15+
LinkGenerator linkGenerator = getLinkGenerator {
16+
group "/api", {
17+
group "/v1", {
18+
group "/books", {
19+
"/" resources:"book"
20+
}
21+
}
22+
}
23+
}
24+
25+
expect:
26+
linkGenerator.link(resource:"book", id:1L, method:"GET") == 'http://localhost/api/v1/books/1'
27+
}
28+
}

0 commit comments

Comments
 (0)