mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Sonar critical bug: inefficient use of keySet iterator instead of entrySet iterator
This commit is contained in:
@@ -105,10 +105,7 @@ public class ScriptConstraint implements Serializable
|
|||||||
constraint.setValues(entry.getValue());
|
constraint.setValues(entry.getValue());
|
||||||
constraints.add(constraint);
|
constraints.add(constraint);
|
||||||
}
|
}
|
||||||
|
return constraints.toArray(new ScriptConstraintAuthority[constraints.size()]);
|
||||||
ScriptConstraintAuthority[] retVal = constraints.toArray(new ScriptConstraintAuthority[constraints.size()]);
|
|
||||||
|
|
||||||
return retVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,17 +209,14 @@ public class ScriptConstraint implements Serializable
|
|||||||
// values, authorities
|
// values, authorities
|
||||||
Map<String, List<String>> pivot = PivotUtil.getPivot(details);
|
Map<String, List<String>> pivot = PivotUtil.getPivot(details);
|
||||||
|
|
||||||
// Here with some data to return
|
|
||||||
Set<String> values = pivot.keySet();
|
|
||||||
|
|
||||||
ArrayList<ScriptConstraintValue> constraints = new ArrayList<>(pivot.size());
|
ArrayList<ScriptConstraintValue> constraints = new ArrayList<>(pivot.size());
|
||||||
for(String value : values)
|
for (Map.Entry<String, List<String>> entry : pivot.entrySet())
|
||||||
{
|
{
|
||||||
ScriptConstraintValue constraint = new ScriptConstraintValue();
|
ScriptConstraintValue constraint = new ScriptConstraintValue();
|
||||||
constraint.setValueName(value);
|
constraint.setValueName(entry.getKey());
|
||||||
constraint.setValueTitle(value);
|
constraint.setValueTitle(entry.getKey());
|
||||||
|
|
||||||
List<String>authorities = pivot.get(value);
|
List<String> authorities = entry.getValue();
|
||||||
List<ScriptAuthority> sauth = new ArrayList<>();
|
List<ScriptAuthority> sauth = new ArrayList<>();
|
||||||
for(String authority : authorities)
|
for(String authority : authorities)
|
||||||
{
|
{
|
||||||
@@ -247,6 +241,7 @@ public class ScriptConstraint implements Serializable
|
|||||||
/**
|
/**
|
||||||
* Now go through and add any "empty" values
|
* Now go through and add any "empty" values
|
||||||
*/
|
*/
|
||||||
|
Set<String> values = pivot.keySet();
|
||||||
for(String value : info.getAllowedValues())
|
for(String value : info.getAllowedValues())
|
||||||
{
|
{
|
||||||
if(!values.contains(value))
|
if(!values.contains(value))
|
||||||
|
Reference in New Issue
Block a user