Merge branch '1.2.x'
This commit is contained in:
commit
5d74ea2861
|
@ -115,12 +115,14 @@ public class ManagementServerProperties implements SecurityPrerequisite {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContextPath(String contextPath) {
|
public void setContextPath(String contextPath) {
|
||||||
|
this.contextPath = cleanContextPath(contextPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String cleanContextPath(String contextPath) {
|
||||||
if (StringUtils.hasText(contextPath) && contextPath.endsWith("/")) {
|
if (StringUtils.hasText(contextPath) && contextPath.endsWith("/")) {
|
||||||
this.contextPath = contextPath.substring(0, contextPath.length() - 1);
|
return contextPath.substring(0, contextPath.length() - 1);
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.contextPath = contextPath;
|
|
||||||
}
|
}
|
||||||
|
return contextPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Security getSecurity() {
|
public Security getSecurity() {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.springframework.boot.actuate.metrics.GaugeService;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.HttpStatus.Series;
|
||||||
import org.springframework.util.StopWatch;
|
import org.springframework.util.StopWatch;
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
import org.springframework.web.servlet.HandlerMapping;
|
import org.springframework.web.servlet.HandlerMapping;
|
||||||
|
@ -96,10 +97,8 @@ final class MetricsFilter extends OncePerRequestFilter {
|
||||||
if (bestMatchingPattern != null) {
|
if (bestMatchingPattern != null) {
|
||||||
return fixSpecialCharacters(bestMatchingPattern.toString());
|
return fixSpecialCharacters(bestMatchingPattern.toString());
|
||||||
}
|
}
|
||||||
if (is4xxClientError(status)) {
|
Series series = getSeries(status);
|
||||||
return UNKNOWN_PATH_SUFFIX;
|
if (Series.CLIENT_ERROR.equals(series) || Series.REDIRECTION.equals(series)) {
|
||||||
}
|
|
||||||
if (is3xxRedirection(status)) {
|
|
||||||
return UNKNOWN_PATH_SUFFIX;
|
return UNKNOWN_PATH_SUFFIX;
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
|
@ -120,22 +119,14 @@ final class MetricsFilter extends OncePerRequestFilter {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean is4xxClientError(int status) {
|
private Series getSeries(int status) {
|
||||||
try {
|
try {
|
||||||
return HttpStatus.valueOf(status).is4xxClientError();
|
return HttpStatus.valueOf(status).series();
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
return false;
|
return null;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean is3xxRedirection(int status) {
|
|
||||||
try {
|
|
||||||
return HttpStatus.valueOf(status).is3xxRedirection();
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getKey(String string) {
|
private String getKey(String string) {
|
||||||
|
|
Loading…
Reference in New Issue