Merge branch '5.2.x'

This commit is contained in:
Rossen Stoyanchev
2020-06-03 06:14:20 +01:00
10 changed files with 77 additions and 34 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-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.
@@ -50,7 +50,7 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource
* @since 5.0.6
*/
public UrlBasedCorsConfigurationSource() {
this(new PathPatternParser());
this(PathPatternParser.defaultInstance);
}
/**

View File

@@ -112,4 +112,35 @@ public class PathPatternParser {
return new InternalPathPatternParser(this).parse(pathPattern);
}
/**
* Shared, read-only instance of {@code PathPatternParser}. Uses default settings:
* <ul>
* <li>{@code matchOptionalTrailingSeparator=true}
* <li>{@code caseSensitivetrue}
* <li>{@code pathOptions=PathContainer.Options.HTTP_PATH}
* </ul>
*/
public final static PathPatternParser defaultInstance = new PathPatternParser() {
@Override
public void setMatchOptionalTrailingSeparator(boolean matchOptionalTrailingSeparator) {
raiseError();
}
@Override
public void setCaseSensitive(boolean caseSensitive) {
raiseError();
}
@Override
public void setPathOptions(PathContainer.Options pathOptions) {
raiseError();
}
private void raiseError() {
throw new UnsupportedOperationException(
"This is a read-only, shared instance that cannot be modified");
}
};
}