From f4af93fb03b84513a8d55c8871a2942b36950b75 Mon Sep 17 00:00:00 2001 From: Krzysztof Krason Date: Thu, 26 Jan 2023 18:32:22 -0800 Subject: [PATCH] Use for loop rather than iterator See gh-33987 --- .../boot/env/ConfigTreePropertySource.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 f72a8714c5..866404b466 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; } }