Skip to content

Commit 46e6aee

Browse files
author
Andrey Turbanov
committed
8295823: Use enhanced-for cycle instead of Enumeration in java.naming
Reviewed-by: aefimov, dfuchs, vtewari
1 parent 8e5d680 commit 46e6aee

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/java.naming/share/classes/javax/naming/directory/BasicAttribute.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ public String toString() {
215215
answer.append("No values");
216216
} else {
217217
boolean start = true;
218-
for (Enumeration<Object> e = values.elements(); e.hasMoreElements(); ) {
218+
for (Object value : values) {
219219
if (!start)
220220
answer.append(", ");
221-
answer.append(e.nextElement());
221+
answer.append(value);
222222
start = false;
223223
}
224224
}

src/java.naming/share/classes/javax/naming/directory/BasicAttributes.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,8 @@ private void writeObject(java.io.ObjectOutputStream s)
294294
// Overridden to avoid exposing implementation details
295295
s.defaultWriteObject(); // write out the ignoreCase flag
296296
s.writeInt(attrs.size());
297-
Enumeration<Attribute> attrEnum = attrs.elements();
298-
while (attrEnum.hasMoreElements()) {
299-
s.writeObject(attrEnum.nextElement());
297+
for (Attribute attribute : attrs.values()) {
298+
s.writeObject(attribute);
300299
}
301300
}
302301

0 commit comments

Comments
 (0)