Weed out duplicate links if there are 2 endpoints with the same path
Fixes gh-3570
This commit is contained in:
parent
38d80bb8c0
commit
ff7717932a
|
|
@ -23,7 +23,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.springframework.beans.factory.ListableBeanFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
|
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure;
|
package org.springframework.boot.actuate.autoconfigure;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
|
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoints;
|
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoints;
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
|
|
@ -24,7 +27,7 @@ import org.springframework.util.StringUtils;
|
||||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds enpoints links to {@link ResourceSupport}.
|
* Adds endpoints links to {@link ResourceSupport}.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
*/
|
*/
|
||||||
|
|
@ -44,10 +47,12 @@ class LinksEnhancer {
|
||||||
resource.add(linkTo(LinksEnhancer.class).slash(this.rootPath + self)
|
resource.add(linkTo(LinksEnhancer.class).slash(this.rootPath + self)
|
||||||
.withSelfRel());
|
.withSelfRel());
|
||||||
}
|
}
|
||||||
|
Set<String> added = new HashSet<String>();
|
||||||
for (MvcEndpoint endpoint : this.endpoints.getEndpoints()) {
|
for (MvcEndpoint endpoint : this.endpoints.getEndpoints()) {
|
||||||
if (!endpoint.getPath().equals(self)) {
|
if (!endpoint.getPath().equals(self) && !added.contains(endpoint.getPath())) {
|
||||||
addEndpointLink(resource, endpoint);
|
addEndpointLink(resource, endpoint);
|
||||||
}
|
}
|
||||||
|
added.add(endpoint.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue