Merge pull request #17825 from dreis2211

* pr/17825:
  Polish some Collections API calls

Closes gh-17825
This commit is contained in:
Stephane Nicoll 2019-08-11 10:36:22 +02:00
commit 01491befc3
3 changed files with 3 additions and 3 deletions

View File

@ -36,7 +36,7 @@ public class JndiPropertiesHidingClassLoader extends ClassLoader {
@Override @Override
public Enumeration<URL> getResources(String name) throws IOException { public Enumeration<URL> getResources(String name) throws IOException {
if ("jndi.properties".equals(name)) { if ("jndi.properties".equals(name)) {
return Collections.enumeration(Collections.emptyList()); return Collections.emptyEnumeration();
} }
return super.getResources(name); return super.getResources(name);
} }

View File

@ -173,7 +173,7 @@ public class ExplodedArchive implements Archive {
private Iterator<File> listFiles(File file) { private Iterator<File> listFiles(File file) {
File[] files = file.listFiles(); File[] files = file.listFiles();
if (files == null) { if (files == null) {
return Collections.<File>emptyList().iterator(); return Collections.emptyIterator();
} }
Arrays.sort(files, this.entryComparator); Arrays.sort(files, this.entryComparator);
return Arrays.asList(files).iterator(); return Arrays.asList(files).iterator();

View File

@ -129,7 +129,7 @@ class SpringBootServletInitializerTests {
given(servletContext.getInitParameterNames()) given(servletContext.getInitParameterNames())
.willReturn(Collections.enumeration(Collections.singletonList("spring.profiles.active"))); .willReturn(Collections.enumeration(Collections.singletonList("spring.profiles.active")));
given(servletContext.getInitParameter("spring.profiles.active")).willReturn("from-servlet-context"); 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() try (ConfigurableApplicationContext context = (ConfigurableApplicationContext) new PropertySourceVerifyingSpringBootServletInitializer()
.createRootApplicationContext(servletContext)) { .createRootApplicationContext(servletContext)) {
assertThat(context.getEnvironment().getActiveProfiles()).containsExactly("from-servlet-context"); assertThat(context.getEnvironment().getActiveProfiles()).containsExactly("from-servlet-context");