diff --git a/spring-web/src/main/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSource.java b/spring-web/src/main/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSource.java index d4720c5a48..f644f9207b 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSource.java +++ b/spring-web/src/main/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -42,12 +42,27 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource private final Map corsConfigurations; private final PathPatternParser patternParser; - + + + /** + * Construct a new {@code UrlBasedCorsConfigurationSource} instance with default + * {@code PathPatternParser}. + * @since 5.0.6 + */ + public UrlBasedCorsConfigurationSource() { + this(new PathPatternParser()); + } + + /** + * Construct a new {@code UrlBasedCorsConfigurationSource} instance from the supplied + * {@code PathPatternParser}. + */ public UrlBasedCorsConfigurationSource(PathPatternParser patternParser) { this.corsConfigurations = new LinkedHashMap<>(); this.patternParser = patternParser; } + /** * Set CORS configuration based on URL patterns. */ diff --git a/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java b/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java index f95a3fe929..137e567ea2 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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. @@ -35,7 +35,7 @@ import static org.junit.Assert.assertNull; public class UrlBasedCorsConfigurationSourceTests { private final UrlBasedCorsConfigurationSource configSource - = new UrlBasedCorsConfigurationSource(new PathPatternParser()); + = new UrlBasedCorsConfigurationSource(); @Test