PMD rule AvoidSynchronizedAtMethodLevel is activated. Issue #744

This commit is contained in:
Roman Ivanov 2015-04-23 19:34:59 -04:00
parent 6b58e1c7fd
commit 18ed7958cf
2 changed files with 8 additions and 7 deletions

View File

@ -113,7 +113,6 @@
<exclude name="ConfusingTernary"/>
<!-- extra final modifier does not make code more secure in that cases-->
<exclude name="ImmutableField"/>
<exclude name="AvoidSynchronizedAtMethodLevel"/>
<exclude name="MissingBreakInSwitch"/>
<exclude name="UseNotifyAllInsteadOfNotify"/>
<exclude name="AvoidInstanceofChecksInCatchClause"/>

View File

@ -138,14 +138,16 @@ public class UniquePropertiesCheck extends AbstractFileSetCheck
.create();
@Override
public synchronized Object put(Object key, Object value)
public Object put(Object key, Object value)
{
final Object oldValue = super.put(key, value);
if (oldValue != null && key instanceof String) {
final String keyString = (String) key;
duplicatedStrings.add(keyString);
synchronized (this) {
final Object oldValue = super.put(key, value);
if (oldValue != null && key instanceof String) {
final String keyString = (String) key;
duplicatedStrings.add(keyString);
}
return oldValue;
}
return oldValue;
}
public Multiset<String> getDuplicatedStrings()