diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java index f72a8714c57..866404b4667 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/ConfigTreePropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; -import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.TreeMap; @@ -229,9 +228,8 @@ public class ConfigTreePropertySource extends EnumerablePropertySource imp } private static boolean hasHiddenPathElement(Path path) { - Iterator iterator = path.iterator(); - while (iterator.hasNext()) { - if (iterator.next().toString().startsWith("..")) { + for (Path element : path) { + if (element.toString().startsWith("..")) { return true; } }