From b605cddb10b05cd4c35d67208a617b3eea1ed3c0 Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Fri, 9 Aug 2019 18:05:04 +0200 Subject: [PATCH] Polish some Collections API calls See gh-17825 --- .../autoconfigure/jndi/JndiPropertiesHidingClassLoader.java | 2 +- .../springframework/boot/loader/archive/ExplodedArchive.java | 2 +- .../web/servlet/support/SpringBootServletInitializerTests.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jndi/JndiPropertiesHidingClassLoader.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jndi/JndiPropertiesHidingClassLoader.java index 991276374d..97fb0f9b32 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jndi/JndiPropertiesHidingClassLoader.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jndi/JndiPropertiesHidingClassLoader.java @@ -36,7 +36,7 @@ public class JndiPropertiesHidingClassLoader extends ClassLoader { @Override public Enumeration getResources(String name) throws IOException { if ("jndi.properties".equals(name)) { - return Collections.enumeration(Collections.emptyList()); + return Collections.emptyEnumeration(); } return super.getResources(name); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java index bf5136c238..e1c860d0c2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java @@ -173,7 +173,7 @@ public class ExplodedArchive implements Archive { private Iterator listFiles(File file) { File[] files = file.listFiles(); if (files == null) { - return Collections.emptyList().iterator(); + return Collections.emptyIterator(); } Arrays.sort(files, this.entryComparator); return Arrays.asList(files).iterator(); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java index 30c2480b71..d4be91bfe1 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java @@ -129,7 +129,7 @@ class SpringBootServletInitializerTests { given(servletContext.getInitParameterNames()) .willReturn(Collections.enumeration(Collections.singletonList("spring.profiles.active"))); given(servletContext.getInitParameter("spring.profiles.active")).willReturn("from-servlet-context"); - given(servletContext.getAttributeNames()).willReturn(Collections.enumeration(Collections.emptyList())); + given(servletContext.getAttributeNames()).willReturn(Collections.emptyEnumeration()); try (ConfigurableApplicationContext context = (ConfigurableApplicationContext) new PropertySourceVerifyingSpringBootServletInitializer() .createRootApplicationContext(servletContext)) { assertThat(context.getEnvironment().getActiveProfiles()).containsExactly("from-servlet-context");