From 46e6aee0d0b868c4c45b7c25cd3fd951d199b1ed Mon Sep 17 00:00:00 2001 From: Andrey Turbanov Date: Wed, 26 Oct 2022 16:50:31 +0000 Subject: [PATCH] 8295823: Use enhanced-for cycle instead of Enumeration in java.naming Reviewed-by: aefimov, dfuchs, vtewari --- .../share/classes/javax/naming/directory/BasicAttribute.java | 4 ++-- .../classes/javax/naming/directory/BasicAttributes.java | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/java.naming/share/classes/javax/naming/directory/BasicAttribute.java b/src/java.naming/share/classes/javax/naming/directory/BasicAttribute.java index b2ab3c22acc..a0b33b76ae7 100644 --- a/src/java.naming/share/classes/javax/naming/directory/BasicAttribute.java +++ b/src/java.naming/share/classes/javax/naming/directory/BasicAttribute.java @@ -215,10 +215,10 @@ public class BasicAttribute implements Attribute { answer.append("No values"); } else { boolean start = true; - for (Enumeration e = values.elements(); e.hasMoreElements(); ) { + for (Object value : values) { if (!start) answer.append(", "); - answer.append(e.nextElement()); + answer.append(value); start = false; } } diff --git a/src/java.naming/share/classes/javax/naming/directory/BasicAttributes.java b/src/java.naming/share/classes/javax/naming/directory/BasicAttributes.java index 0e1dc83a521..fcfa09c9d38 100644 --- a/src/java.naming/share/classes/javax/naming/directory/BasicAttributes.java +++ b/src/java.naming/share/classes/javax/naming/directory/BasicAttributes.java @@ -294,9 +294,8 @@ public class BasicAttributes implements Attributes { // Overridden to avoid exposing implementation details s.defaultWriteObject(); // write out the ignoreCase flag s.writeInt(attrs.size()); - Enumeration attrEnum = attrs.elements(); - while (attrEnum.hasMoreElements()) { - s.writeObject(attrEnum.nextElement()); + for (Attribute attribute : attrs.values()) { + s.writeObject(attribute); } }