Sonar critical bug: inefficient use of keySet iterator instead of entrySet iterator

This commit is contained in:
cagache
2019-07-02 12:06:13 +03:00
parent 7782d7d448
commit 6e2826f78c
3 changed files with 12 additions and 15 deletions

View File

@@ -255,22 +255,23 @@ public final class RecordsManagementAuditEntry
this.beforeProperties.size() + this.afterProperties.size());
// add all the properties present before the audited action
for (QName valuePropName : this.beforeProperties.keySet())
for (Map.Entry<QName, Serializable> entry : this.beforeProperties.entrySet())
{
final QName valuePropName = entry.getKey();
Pair<Serializable, Serializable> values = new Pair<>(
this.beforeProperties.get(valuePropName),
entry.getValue(),
this.afterProperties.get(valuePropName));
this.changedProperties.put(valuePropName, values);
}
// add all the properties present after the audited action that
// have not already been added
for (QName valuePropName : this.afterProperties.keySet())
for (Map.Entry<QName, Serializable> entry : this.afterProperties.entrySet())
{
final QName valuePropName = entry.getKey();
if (!this.beforeProperties.containsKey(valuePropName))
{
Pair<Serializable, Serializable> values = new Pair<>(null,
this.afterProperties.get(valuePropName));
Pair<Serializable, Serializable> values = new Pair<>(null, entry.getValue());
this.changedProperties.put(valuePropName, values);
}
}