diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java index 7b26846eeb..565d191f29 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java @@ -166,7 +166,7 @@ class EndpointDiscovererTests { void getEndpointsWhenTtlSetByIdAndIdDoesNotMatchShouldNotCacheInvokeCalls() { load(TestEndpointConfiguration.class, (context) -> { TestEndpointDiscoverer discoverer = new TestEndpointDiscoverer(context, - (endpointId) -> (endpointId.equals("foo") ? 500L : 0L)); + (endpointId) -> (endpointId.equals(EndpointId.of("foo")) ? 500L : 0L)); Map endpoints = mapEndpoints(discoverer.getEndpoints()); assertThat(endpoints).containsOnlyKeys(EndpointId.of("test")); Map operations = mapOperations(endpoints.get(EndpointId.of("test"))); diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java index bf82090e67..f065c33895 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java @@ -17,7 +17,7 @@ package org.springframework.boot.test.json; import java.net.URL; -import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.List; @@ -57,17 +57,14 @@ class DuplicateJsonObjectContextCustomizerFactory implements ContextCustomizerFa } private List findJsonObjects() { - List jsonObjects = new ArrayList<>(); try { Enumeration resources = getClass().getClassLoader().getResources("org/json/JSONObject.class"); - while (resources.hasMoreElements()) { - jsonObjects.add(resources.nextElement()); - } + return Collections.list(resources); } catch (Exception ex) { // Continue } - return jsonObjects; + return Collections.emptyList(); } private void logDuplicateJsonObjectsWarning(List jsonObjects) {