Browse Source

Weed out duplicate links if there are 2 endpoints with the same path

Fixes gh-3570
pull/3564/merge
Dave Syer 11 years ago
parent
commit
ff7717932a
  1. 1
      spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.java
  2. 9
      spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/LinksEnhancer.java

1
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.java

@ -23,7 +23,6 @@ import java.util.concurrent.ConcurrentHashMap; @@ -23,7 +23,6 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;

9
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/LinksEnhancer.java

@ -16,6 +16,9 @@ @@ -16,6 +16,9 @@
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.MvcEndpoints;
import org.springframework.hateoas.ResourceSupport;
@ -24,7 +27,7 @@ import org.springframework.util.StringUtils; @@ -24,7 +27,7 @@ import org.springframework.util.StringUtils;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
/**
* Adds enpoints links to {@link ResourceSupport}.
* Adds endpoints links to {@link ResourceSupport}.
*
* @author Dave Syer
*/
@ -44,10 +47,12 @@ class LinksEnhancer { @@ -44,10 +47,12 @@ class LinksEnhancer {
resource.add(linkTo(LinksEnhancer.class).slash(this.rootPath + self)
.withSelfRel());
}
Set<String> added = new HashSet<String>();
for (MvcEndpoint endpoint : this.endpoints.getEndpoints()) {
if (!endpoint.getPath().equals(self)) {
if (!endpoint.getPath().equals(self) && !added.contains(endpoint.getPath())) {
addEndpointLink(resource, endpoint);
}
added.add(endpoint.getPath());
}
}

Loading…
Cancel
Save