8295823: Use enhanced-for cycle instead of Enumeration in java.naming

Reviewed-by: aefimov, dfuchs, vtewari
This commit is contained in:
Andrey Turbanov 2022-10-26 16:50:31 +00:00
parent 8e5d680a98
commit 46e6aee0d0
2 changed files with 4 additions and 5 deletions

View File

@ -215,10 +215,10 @@ public class BasicAttribute implements Attribute {
answer.append("No values");
} else {
boolean start = true;
for (Enumeration<Object> e = values.elements(); e.hasMoreElements(); ) {
for (Object value : values) {
if (!start)
answer.append(", ");
answer.append(e.nextElement());
answer.append(value);
start = false;
}
}

View File

@ -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<Attribute> attrEnum = attrs.elements();
while (attrEnum.hasMoreElements()) {
s.writeObject(attrEnum.nextElement());
for (Attribute attribute : attrs.values()) {
s.writeObject(attribute);
}
}