Skip to content
Permalink
Browse files
8274318: Replace 'for' cycles with iterator with enhanced-for in java…
….management

Reviewed-by: cjplummer, sspitsyn, dfuchs
  • Loading branch information
turbanoff authored and dfuch committed Oct 6, 2021
1 parent 754bc82 commit 9945f7a0744db2470bcfa856e8f831b6a6eb2de8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -494,8 +494,7 @@ private static synchronized String makeConnectionId(String protocol,
if (subject != null) {
Set<Principal> principals = subject.getPrincipals();
String sep = "";
for (Iterator<Principal> it = principals.iterator(); it.hasNext(); ) {
Principal p = it.next();
for (Principal p : principals) {
String name = p.getName().replace(' ', '_').replace(';', ':');
buf.append(sep).append(name);
sep = ";";
@@ -33,7 +33,6 @@
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -314,8 +313,7 @@ public Subject run() {
if (s == null) return; /* security has not been enabled */
final Set<Principal> principals = s.getPrincipals();
String newPropertyValue = null;
for (Iterator<Principal> i = principals.iterator(); i.hasNext(); ) {
final Principal p = i.next();
for (Principal p : principals) {
Access access = accessMap.get(p.getName());
if (access != null) {
boolean ok;
@@ -35,7 +35,6 @@
import java.io.Serializable;

import java.security.AccessController;
import java.util.Iterator;

/**
* Represents the result of a multiple access to several roles of a relation
@@ -132,7 +131,6 @@ public RoleResult(RoleList list,

setRoles(list);
setRolesUnresolved(unresolvedList);
return;
}

//
@@ -173,15 +171,13 @@ public void setRoles(RoleList list) {

roleList = new RoleList();

for (Iterator<?> roleIter = list.iterator();
roleIter.hasNext();) {
Role currRole = (Role)(roleIter.next());
roleList.add((Role)(currRole.clone()));
for (Object o : list) {
Role currRole = (Role)o;
roleList.add((Role)currRole.clone());
}
} else {
roleList = null;
}
return;
}

/**
@@ -196,16 +192,13 @@ public void setRolesUnresolved(RoleUnresolvedList unresolvedList) {

unresolvedRoleList = new RoleUnresolvedList();

for (Iterator<?> roleUnresIter = unresolvedList.iterator();
roleUnresIter.hasNext();) {
RoleUnresolved currRoleUnres =
(RoleUnresolved)(roleUnresIter.next());
unresolvedRoleList.add((RoleUnresolved)(currRoleUnres.clone()));
for (Object o : unresolvedList) {
RoleUnresolved currRoleUnres = (RoleUnresolved)o;
unresolvedRoleList.add((RoleUnresolved)currRoleUnres.clone());
}
} else {
unresolvedRoleList = null;
}
return;
}

/**

1 comment on commit 9945f7a

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 9945f7a Oct 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.