Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #147 by using the base path attribute instead for 2.6 compatibility. #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2019 The OpenTracing Authors
* Copyright 2016-2021 The OpenTracing 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
Expand Down Expand Up @@ -65,13 +65,17 @@ protected static class ManagementSkipPatternProviderConfig {

static Optional<Pattern> getPatternForManagementServerProperties(
ManagementServerProperties managementServerProperties) {
String contextPath = managementServerProperties.getServlet().getContextPath();
String contextPath = managementServerProperties.getBasePath();
if (StringUtils.hasText(contextPath)) {
return Optional.of(Pattern.compile(contextPath + ".*"));
return Optional.of(Pattern.compile(cleanup(contextPath) + ".*"));
}
return Optional.empty();
}

private static String cleanup(String contextPath) {
return contextPath.startsWith("/") ? contextPath.substring(1) : contextPath;
}

@Bean
@ConditionalOnBean(ManagementServerProperties.class)
public SkipPattern skipPatternForManagementServerProperties(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2019 The OpenTracing Authors
* Copyright 2016-2021 The OpenTracing 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
Expand Down Expand Up @@ -62,10 +62,21 @@ public void testShouldReturnEmptyWhenManagementContextHasNoContextPath() {
then(pattern).isEmpty();
}

@Test
public void testShouldReturnEmptyWhenManagementContextHasOnlyARootSlashHasContextPath() {
ManagementServerProperties properties = new ManagementServerProperties();
properties.setBasePath("/");

Optional<Pattern> pattern = new SkipPatternAutoConfiguration.ManagementSkipPatternProviderConfig()
.skipPatternForManagementServerProperties(properties).pattern();

then(pattern).isEmpty();
}

@Test
public void testShouldReturnManagementContextWithContextPath() {
ManagementServerProperties properties = new ManagementServerProperties();
properties.getServlet().setContextPath("foo");
properties.setBasePath("foo");

Optional<Pattern> pattern = new SkipPatternAutoConfiguration.ManagementSkipPatternProviderConfig()
.skipPatternForManagementServerProperties(properties).pattern();
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2016-2020 The OpenTracing Authors
Copyright 2016-2021 The OpenTracing 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
Expand Down Expand Up @@ -64,9 +64,9 @@
<version.io.opentracing.contrib-opentracing-spring-tracer-configuration-starter>0.4.0</version.io.opentracing.contrib-opentracing-spring-tracer-configuration-starter>
<version.junit>4.13.1</version.junit>
<version.org.mockito-mockito-core>2.23.4</version.org.mockito-mockito-core>
<version.org.springframework.boot>2.3.4.RELEASE</version.org.springframework.boot>
<version.org.springframework.boot>2.4.0</version.org.springframework.boot>
<!-- Should match version from https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-dependencies/pom.xml -->
<version.org.springframework>5.2.9.RELEASE</version.org.springframework>
<version.org.springframework>5.3.1</version.org.springframework>
<version.com.github.tomakehurst-wiremock-jre8>2.21.0</version.com.github.tomakehurst-wiremock-jre8>
<version.io.projectreactor.netty-reactor-netty>0.9.12.RELEASE</version.io.projectreactor.netty-reactor-netty>

Expand Down