Update to new location of management context path property.

This commit is contained in:
Spencer Gibb
2018-01-18 14:40:49 -05:00
parent ef4537800a
commit 9f716d7d92
3 changed files with 13 additions and 16 deletions

View File

@@ -68,21 +68,20 @@ public class TraceWebAutoConfiguration {
}
/**
* Sets or appends {@link ManagementServerProperties#getContextPath()} to the skip
* Sets or appends {@link ManagementServerProperties.Servlet#getContextPath()} to the skip
* pattern. If neither is available then sets the default one
*/
static Pattern getPatternForManagementServerProperties(
ManagementServerProperties managementServerProperties,
SleuthWebProperties sleuthWebProperties) {
String skipPattern = sleuthWebProperties.getSkipPattern();
if (StringUtils.hasText(skipPattern)
&& StringUtils.hasText(managementServerProperties.getContextPath())) {
return Pattern.compile(skipPattern + "|"
+ managementServerProperties.getContextPath() + ".*");
String contextPath = managementServerProperties.getServlet().getContextPath();
if (StringUtils.hasText(skipPattern) && StringUtils.hasText(contextPath)) {
return Pattern.compile(skipPattern + "|" + contextPath + ".*");
}
else if (StringUtils.hasText(managementServerProperties.getContextPath())) {
return Pattern
.compile(managementServerProperties.getContextPath() + ".*");
else if (StringUtils.hasText(contextPath)) {
return Pattern.compile(contextPath + ".*");
}
return defaultSkipPattern(skipPattern);
}

View File

@@ -64,20 +64,18 @@ public class SkipPatternProviderConfigTest {
SleuthWebProperties sleuthWebProperties = new SleuthWebProperties();
sleuthWebProperties.setSkipPattern("");
ManagementServerProperties properties = new ManagementServerProperties();
properties.getServlet().setContextPath("");
Pattern pattern = TraceWebAutoConfiguration.SkipPatternProviderConfig.getPatternForManagementServerProperties(
new ManagementServerProperties() {
@Override
public String getContextPath() {
return "";
}
}, sleuthWebProperties);
properties, sleuthWebProperties);
then(pattern.pattern()).isEqualTo(SleuthWebProperties.DEFAULT_SKIP_PATTERN);
}
private ManagementServerProperties managementServerPropertiesWithContextPath() {
ManagementServerProperties managementServerProperties = new ManagementServerProperties();
managementServerProperties.setContextPath("/management/context");
managementServerProperties.getServlet().setContextPath("/management/context");
return managementServerProperties;
}
}

View File

@@ -289,7 +289,7 @@ public class TraceFilterIntegrationTests extends AbstractMvcIntegrationTest {
@Primary
ManagementServerProperties managementServerProperties() {
ManagementServerProperties managementServerProperties = new ManagementServerProperties();
managementServerProperties.setContextPath("/additionalContextPath");
managementServerProperties.getServlet().setContextPath("/additionalContextPath");
return managementServerProperties;
}
}