Compare commits

...

12 Commits
main ... 3.0.x

Author SHA1 Message Date
buildmaster 1af1f635f9 Bumping versions 1 year ago
buildmaster eb6a5dab37 Bumping versions to 3.0.9-SNAPSHOT after release 2 years ago
buildmaster ac469d316d Going back to snapshots 2 years ago
buildmaster b0c4246d57 Update SNAPSHOT to 3.0.8 2 years ago
Alberto C. Ríos 7476673326
Updating log level when invalid route (#2616) 2 years ago
buildmaster 6b0bafdd42 Bumping versions 3 years ago
buildmaster 88a6b23248 Bumping versions to 3.0.8-SNAPSHOT after release 3 years ago
buildmaster 60849189b6 Going back to snapshots 3 years ago
buildmaster 2b4b39598d Update SNAPSHOT to 3.0.7 3 years ago
spencergibb 2283faa393
Separates ShortcutConfigurableNonRestrictiveTests 3 years ago
spencergibb 1b868d2159
Adds spring.cloud.gateway.restrictive-property-accessor.enabled 3 years ago
spencergibb bec3dc0e68
Updates ShortcutConfigurable to use custom EvaluationContext. 3 years ago
  1. 72
      README.adoc
  2. 2
      docs/pom.xml
  3. 3
      docs/src/main/asciidoc/_configprops.adoc
  4. 8
      pom.xml
  5. 2
      spring-cloud-gateway-dependencies/pom.xml
  6. 2
      spring-cloud-gateway-integration-tests/mvc-failure-analyzer/pom.xml
  7. 2
      spring-cloud-gateway-integration-tests/pom.xml
  8. 2
      spring-cloud-gateway-mvc/pom.xml
  9. 2
      spring-cloud-gateway-sample/pom.xml
  10. 2
      spring-cloud-gateway-server/pom.xml
  11. 2
      spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/actuate/AbstractGatewayControllerEndpoint.java
  12. 106
      spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/support/ShortcutConfigurable.java
  13. 6
      spring-cloud-gateway-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json
  14. 110
      spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/support/ShortcutConfigurableNonRestrictiveTests.java
  15. 74
      spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/support/ShortcutConfigurableTests.java
  16. 2
      spring-cloud-gateway-webflux/pom.xml
  17. 2
      spring-cloud-starter-gateway/pom.xml

72
README.adoc

@ -28,7 +28,8 @@ This project provides an API Gateway built on top of the Spring Ecosystem, inclu @@ -28,7 +28,8 @@ This project provides an API Gateway built on top of the Spring Ecosystem, inclu
== Building
:jdkversion: 1.8
:jdkversion: 17
=== Basic Compile and Test
@ -54,23 +55,9 @@ the `.mvn` configuration, so if you find you have to do it to make a @@ -54,23 +55,9 @@ the `.mvn` configuration, so if you find you have to do it to make a
build succeed, please raise a ticket to get the settings added to
source control.
For hints on how to build the project look in `.travis.yml` if there
is one. There should be a "script" and maybe "install" command. Also
look at the "services" section to see if any services need to be
running locally (e.g. mongo or rabbit). Ignore the git-related bits
that you might find in "before_install" since they're related to setting git
credentials and you already have those.
The projects that require middleware generally include a
`docker-compose.yml`, so consider using
https://docs.docker.com/compose/[Docker Compose] to run the middeware servers
in Docker containers. See the README in the
https://github.com/spring-cloud-samples/scripts[scripts demo
repository] for specific instructions about the common cases of mongo,
rabbit and redis.
The projects that require middleware (i.e. Redis) for testing generally
require that a local instance of [Docker](https://www.docker.com/get-started) is installed and running.
NOTE: If all else fails, build with the command from `.travis.yml` (usually
`./mvnw install`).
=== Documentation
@ -304,3 +291,54 @@ Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on t @@ -304,3 +291,54 @@ Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on t
- `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`.
IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources.
=== Duplicate Finder
Spring Cloud Build brings along the `basepom:duplicate-finder-maven-plugin`, that enables flagging duplicate and conflicting classes and resources on the java classpath.
==== Duplicate Finder configuration
Duplicate finder is *enabled by default* and will run in the `verify` phase of your Maven build, but it will only take effect in your project if you add the `duplicate-finder-maven-plugin` to the `build` section of the projecst's `pom.xml`.
.pom.xml
[source,xml]
----
<build>
<plugins>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
----
For other properties, we have set defaults as listed in the https://github.com/basepom/duplicate-finder-maven-plugin/wiki[plugin documentation].
You can easily override them but setting the value of the selected property prefixed with `duplicate-finder-maven-plugin`. For example, set `duplicate-finder-maven-plugin.skip` to `true` in order to skip duplicates check in your build.
If you need to add `ignoredClassPatterns` or `ignoredResourcePatterns` to your setup, make sure to add them in the plugin configuration section of your project:
[source,xml]
----
<build>
<plugins>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
<configuration>
<ignoredClassPatterns>
<ignoredClassPattern>org.joda.time.base.BaseDateTime</ignoredClassPattern>
<ignoredClassPattern>.*module-info</ignoredClassPattern>
</ignoredClassPatterns>
<ignoredResourcePatterns>
<ignoredResourcePattern>changelog.txt</ignoredResourcePattern>
</ignoredResourcePatterns>
</configuration>
</plugin>
</plugins>
</build>
----

2
docs/pom.xml

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>3.0.9-SNAPSHOT</version>
</parent>
<artifactId>spring-cloud-gateway-docs</artifactId>
<packaging>jar</packaging>

3
docs/src/main/asciidoc/_configprops.adoc

@ -70,6 +70,7 @@ @@ -70,6 +70,7 @@
|spring.cloud.gateway.global-filter.websocket-routing.enabled | `true` | Enables the websocket-routing global filter.
|spring.cloud.gateway.globalcors.add-to-simple-url-handler-mapping | `false` | If global CORS config should be added to the URL handler.
|spring.cloud.gateway.globalcors.cors-configurations | |
|spring.cloud.gateway.handler-mapping.order | `1` | The order of RoutePredicateHandlerMapping.
|spring.cloud.gateway.httpclient.compression | `false` | Enables compression for Netty HttpClient.
|spring.cloud.gateway.httpclient.connect-timeout | | The connect timeout in millis, the default is 45s.
|spring.cloud.gateway.httpclient.max-header-size | | The max response header size.
@ -108,7 +109,6 @@ @@ -108,7 +109,6 @@
|spring.cloud.gateway.metrics.enabled | `false` | Enables the collection of metrics data.
|spring.cloud.gateway.metrics.prefix | `spring.cloud.gateway` | The prefix of all metrics emitted by gateway.
|spring.cloud.gateway.metrics.tags | | Tags map that added to metrics.
|spring.cloud.gateway.metrics.tags.path.enabled | `false` | If the collection of metrics data is enabled, enables an extra metric data tag by path.
|spring.cloud.gateway.predicate.after.enabled | `true` | Enables the after predicate.
|spring.cloud.gateway.predicate.before.enabled | `true` | Enables the before predicate.
|spring.cloud.gateway.predicate.between.enabled | `true` | Enables the between predicate.
@ -128,6 +128,7 @@ @@ -128,6 +128,7 @@
|spring.cloud.gateway.redis-rate-limiter.remaining-header | `X-RateLimit-Remaining` | The name of the header that returns number of remaining requests during the current second.
|spring.cloud.gateway.redis-rate-limiter.replenish-rate-header | `X-RateLimit-Replenish-Rate` | The name of the header that returns the replenish rate configuration.
|spring.cloud.gateway.redis-rate-limiter.requested-tokens-header | `X-RateLimit-Requested-Tokens` | The name of the header that returns the requested tokens configuration.
|spring.cloud.gateway.restrictive-property-accessor.enabled | `true` | Restricts method and property access in SpEL.
|spring.cloud.gateway.routes | | List of Routes.
|spring.cloud.gateway.set-status.original-status-header-name | | The name of the header which contains http code of the proxied request.
|spring.cloud.gateway.streaming-media-types | |

8
pom.xml

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>3.0.9-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Spring Cloud Gateway</name>
@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>3.0.5</version>
<version>3.0.6-SNAPSHOT</version>
<relativePath/>
</parent>
<scm>
@ -54,8 +54,8 @@ @@ -54,8 +54,8 @@
<blockhound.version>1.0.6.RELEASE</blockhound.version>
<java.version>1.8</java.version>
<junit-pioneer.version>1.0.0</junit-pioneer.version>
<spring-cloud-circuitbreaker.version>2.0.2</spring-cloud-circuitbreaker.version>
<spring-cloud-commons.version>3.0.6-SNAPSHOT</spring-cloud-commons.version>
<spring-cloud-circuitbreaker.version>2.0.4-SNAPSHOT</spring-cloud-circuitbreaker.version>
<spring-cloud-commons.version>3.0.7-SNAPSHOT</spring-cloud-commons.version>
<testcontainers.version>1.15.1</testcontainers.version>
</properties>

2
spring-cloud-gateway-dependencies/pom.xml

@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
</parent>
<artifactId>spring-cloud-gateway-dependencies</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>3.0.9-SNAPSHOT</version>
<packaging>pom</packaging>
<name>spring-cloud-gateway-dependencies</name>

2
spring-cloud-gateway-integration-tests/mvc-failure-analyzer/pom.xml

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-integration-tests</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>3.0.9-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

2
spring-cloud-gateway-integration-tests/pom.xml

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>3.0.9-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

2
spring-cloud-gateway-mvc/pom.xml

@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>3.0.9-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

2
spring-cloud-gateway-sample/pom.xml

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>3.0.9-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

2
spring-cloud-gateway-server/pom.xml

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>3.0.9-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-gateway-server</artifactId>

2
spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/actuate/AbstractGatewayControllerEndpoint.java

@ -160,7 +160,7 @@ public class AbstractGatewayControllerEndpoint implements ApplicationEventPublis @@ -160,7 +160,7 @@ public class AbstractGatewayControllerEndpoint implements ApplicationEventPublis
private void handleUnavailableDefinition(String simpleName, Set<String> unavailableDefinitions) {
final String errorMessage = String.format("Invalid %s: %s", simpleName, unavailableDefinitions);
log.debug(errorMessage);
log.warn(errorMessage);
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, errorMessage);
}

106
spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/support/ShortcutConfigurable.java

@ -25,10 +25,23 @@ import java.util.stream.Collectors; @@ -25,10 +25,23 @@ import java.util.stream.Collectors;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.expression.BeanFactoryResolver;
import org.springframework.core.env.Environment;
import org.springframework.expression.BeanResolver;
import org.springframework.expression.ConstructorResolver;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.MethodResolver;
import org.springframework.expression.OperatorOverloader;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypeComparator;
import org.springframework.expression.TypeConverter;
import org.springframework.expression.TypeLocator;
import org.springframework.expression.TypedValue;
import org.springframework.expression.common.TemplateParserContext;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.expression.spel.support.ReflectivePropertyAccessor;
import org.springframework.expression.spel.support.SimpleEvaluationContext;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -54,8 +67,7 @@ public interface ShortcutConfigurable { @@ -54,8 +67,7 @@ public interface ShortcutConfigurable {
}
if (rawValue != null && rawValue.startsWith("#{") && entryValue.endsWith("}")) {
// assume it's spel
StandardEvaluationContext context = new StandardEvaluationContext();
context.setBeanResolver(new BeanFactoryResolver(beanFactory));
GatewayEvaluationContext context = new GatewayEvaluationContext(beanFactory);
Expression expression = parser.parseExpression(entryValue, new TemplateParserContext());
value = expression.getValue(context);
}
@ -148,4 +160,92 @@ public interface ShortcutConfigurable { @@ -148,4 +160,92 @@ public interface ShortcutConfigurable {
}
class GatewayEvaluationContext implements EvaluationContext {
private final BeanFactoryResolver beanFactoryResolver;
private final SimpleEvaluationContext delegate;
public GatewayEvaluationContext(BeanFactory beanFactory) {
this.beanFactoryResolver = new BeanFactoryResolver(beanFactory);
Environment env = beanFactory.getBean(Environment.class);
boolean restrictive = env.getProperty("spring.cloud.gateway.restrictive-property-accessor.enabled",
Boolean.class, true);
if (restrictive) {
delegate = SimpleEvaluationContext.forPropertyAccessors(new RestrictivePropertyAccessor())
.withMethodResolvers((context, targetObject, name, argumentTypes) -> null).build();
}
else {
delegate = SimpleEvaluationContext.forReadOnlyDataBinding().build();
}
}
@Override
public TypedValue getRootObject() {
return delegate.getRootObject();
}
@Override
public List<PropertyAccessor> getPropertyAccessors() {
return delegate.getPropertyAccessors();
}
@Override
public List<ConstructorResolver> getConstructorResolvers() {
return delegate.getConstructorResolvers();
}
@Override
public List<MethodResolver> getMethodResolvers() {
return delegate.getMethodResolvers();
}
@Override
@Nullable
public BeanResolver getBeanResolver() {
return this.beanFactoryResolver;
}
@Override
public TypeLocator getTypeLocator() {
return delegate.getTypeLocator();
}
@Override
public TypeConverter getTypeConverter() {
return delegate.getTypeConverter();
}
@Override
public TypeComparator getTypeComparator() {
return delegate.getTypeComparator();
}
@Override
public OperatorOverloader getOperatorOverloader() {
return delegate.getOperatorOverloader();
}
@Override
public void setVariable(String name, Object value) {
delegate.setVariable(name, value);
}
@Override
@Nullable
public Object lookupVariable(String name) {
return delegate.lookupVariable(name);
}
}
class RestrictivePropertyAccessor extends ReflectivePropertyAccessor {
@Override
public boolean canRead(EvaluationContext context, Object target, String name) {
return false;
}
}
}

6
spring-cloud-gateway-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json

@ -365,6 +365,12 @@ @@ -365,6 +365,12 @@
"type": "java.lang.Integer",
"description": "The order of RoutePredicateHandlerMapping.",
"defaultValue": "1"
},
{
"name": "spring.cloud.gateway.restrictive-property-accessor.enabled",
"type": "java.lang.Boolean",
"description": "Restricts method and property access in SpEL.",
"defaultValue": "true"
}
]
}

110
spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/support/ShortcutConfigurableNonRestrictiveTests.java

@ -0,0 +1,110 @@ @@ -0,0 +1,110 @@
/*
* Copyright 2013-2020 the original author or authors.
*
* Licensed 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 org.springframework.cloud.gateway.support;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.support.ShortcutConfigurable.ShortcutType;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(properties = "spring.cloud.gateway.restrictive-property-accessor.enabled=false")
public class ShortcutConfigurableNonRestrictiveTests {
@Autowired
BeanFactory beanFactory;
@Autowired
ConfigurableEnvironment env;
private SpelExpressionParser parser;
@Test
public void testNormalizeDefaultTypeWithSpelAndPropertyReferenceEnabled() {
parser = new SpelExpressionParser();
ShortcutConfigurable shortcutConfigurable = new ShortcutConfigurable() {
@Override
public List<String> shortcutFieldOrder() {
return Arrays.asList("bean", "arg1");
}
};
Map<String, String> args = new HashMap<>();
args.put("barproperty", "#{@bar.getInt}");
args.put("arg1", "val1");
Map<String, Object> map = ShortcutType.DEFAULT.normalize(args, shortcutConfigurable, parser, this.beanFactory);
assertThat(map).isNotNull().containsEntry("barproperty", 42).containsEntry("arg1", "val1");
}
@Test
public void testNormalizeDefaultTypeWithSpelAndMethodReferenceEnabled() {
parser = new SpelExpressionParser();
ShortcutConfigurable shortcutConfigurable = new ShortcutConfigurable() {
@Override
public List<String> shortcutFieldOrder() {
return Arrays.asList("bean", "arg1");
}
};
Map<String, String> args = new HashMap<>();
args.put("barmethod", "#{@bar.myMethod}");
args.put("arg1", "val1");
Map<String, Object> map = ShortcutType.DEFAULT.normalize(args, shortcutConfigurable, parser, this.beanFactory);
assertThat(map).isNotNull().containsEntry("barmethod", 42).containsEntry("arg1", "val1");
}
@SpringBootConfiguration
protected static class TestConfig {
@Bean
public Integer foo() {
return 42;
}
@Bean
public Bar bar() {
return new Bar();
}
}
protected static class Bar {
public int getInt() {
return 42;
}
public int myMethod() {
return 42;
}
}
}

74
spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/support/ShortcutConfigurableTests.java

@ -30,10 +30,13 @@ import org.springframework.boot.SpringBootConfiguration; @@ -30,10 +30,13 @@ import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.gateway.support.ShortcutConfigurable.ShortcutType;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@RunWith(SpringRunner.class)
@SpringBootTest
@ -42,8 +45,62 @@ public class ShortcutConfigurableTests { @@ -42,8 +45,62 @@ public class ShortcutConfigurableTests {
@Autowired
BeanFactory beanFactory;
@Autowired
ConfigurableEnvironment env;
private SpelExpressionParser parser;
@Test
public void testNormalizeDefaultTypeWithSpelAndInvalidInputFails() {
parser = new SpelExpressionParser();
ShortcutConfigurable shortcutConfigurable = new ShortcutConfigurable() {
@Override
public List<String> shortcutFieldOrder() {
return Arrays.asList("bean", "arg1");
}
};
Map<String, String> args = new HashMap<>();
args.put("bean", "#{T(java.lang.Runtime).getRuntime().exec(\"touch /tmp/x\")}");
args.put("arg1", "val1");
assertThatThrownBy(() -> {
ShortcutType.DEFAULT.normalize(args, shortcutConfigurable, parser, this.beanFactory);
}).isInstanceOf(SpelEvaluationException.class);
}
@Test
public void testNormalizeDefaultTypeWithSpelAndInvalidPropertyReferenceFails() {
parser = new SpelExpressionParser();
ShortcutConfigurable shortcutConfigurable = new ShortcutConfigurable() {
@Override
public List<String> shortcutFieldOrder() {
return Arrays.asList("bean", "arg1");
}
};
Map<String, String> args = new HashMap<>();
args.put("barproperty", "#{@bar.getInt}");
args.put("arg1", "val1");
assertThatThrownBy(() -> {
ShortcutType.DEFAULT.normalize(args, shortcutConfigurable, parser, this.beanFactory);
}).isInstanceOf(SpelEvaluationException.class);
}
@Test
public void testNormalizeDefaultTypeWithSpelAndInvalidMethodReferenceFails() {
parser = new SpelExpressionParser();
ShortcutConfigurable shortcutConfigurable = new ShortcutConfigurable() {
@Override
public List<String> shortcutFieldOrder() {
return Arrays.asList("bean", "arg1");
}
};
Map<String, String> args = new HashMap<>();
args.put("barmethod", "#{@bar.myMethod}");
args.put("arg1", "val1");
assertThatThrownBy(() -> {
ShortcutType.DEFAULT.normalize(args, shortcutConfigurable, parser, this.beanFactory);
}).isInstanceOf(SpelEvaluationException.class);
}
@Test
public void testNormalizeDefaultTypeWithSpel() {
parser = new SpelExpressionParser();
@ -136,6 +193,23 @@ public class ShortcutConfigurableTests { @@ -136,6 +193,23 @@ public class ShortcutConfigurableTests {
return 42;
}
@Bean
public Bar bar() {
return new Bar();
}
}
protected static class Bar {
public int getInt() {
return 42;
}
public int myMethod() {
return 42;
}
}
}

2
spring-cloud-gateway-webflux/pom.xml

@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>3.0.9-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

2
spring-cloud-starter-gateway/pom.xml

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>3.0.9-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-starter-gateway</artifactId>

Loading…
Cancel
Save