diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/MockServletWebServer.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/MockServletWebServer.java index 8cb9919458..fdfcf883af 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/MockServletWebServer.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/MockServletWebServer.java @@ -18,11 +18,9 @@ package org.springframework.boot.testsupport.web.servlet; import java.util.ArrayList; import java.util.Collections; -import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.NoSuchElementException; import javax.servlet.Filter; import javax.servlet.FilterRegistration; @@ -93,7 +91,7 @@ public abstract class MockServletWebServer { given(this.servletContext.getInitParameter(anyString())).willAnswer( (invocation) -> initParameters.get(invocation.getArgument(0))); given(this.servletContext.getAttributeNames()) - .willReturn(MockServletWebServer.emptyEnumeration()); + .willReturn(Collections.emptyEnumeration()); given(this.servletContext.getNamedDispatcher("default")) .willReturn(mock(RequestDispatcher.class)); for (Initializer initializer : this.initializers) { @@ -142,27 +140,6 @@ public abstract class MockServletWebServer { return this.port; } - @SuppressWarnings("unchecked") - public static Enumeration emptyEnumeration() { - return (Enumeration) EmptyEnumeration.EMPTY_ENUMERATION; - } - - private static class EmptyEnumeration implements Enumeration { - - static final MockServletWebServer.EmptyEnumeration EMPTY_ENUMERATION = new MockServletWebServer.EmptyEnumeration<>(); - - @Override - public boolean hasMoreElements() { - return false; - } - - @Override - public E nextElement() { - throw new NoSuchElementException(); - } - - } - /** * A registered servlet. */