From e936c4c6fae73ec4c53aa8f2f9db302d064e1b8e Mon Sep 17 00:00:00 2001 From: Michal Kordas Date: Sat, 15 Aug 2015 22:36:48 +0200 Subject: [PATCH] Remove unnecessary synchronization. #1555 Fixes `NonSerializableFieldInSerializableClass` inspection violation. Description: >Reports non-synchronized methods overriding synchronized methods. Fixes `NonSynchronizedMethodOverridesSynchronizedMethod` inspection violation. Description: >Reports non-Serializable fields in Serializable classes. Such fields will result in runtime exceptions if the object is serialized. Fields declared transient or static are not reported, nor are fields of classes which have defined a writeObject method. For purposes of this inspection, fields with java.util.Collection or java.util.Map types are assumed to be Serializable, unless the types they are declared to contain are non-Serializable. --- .../checkstyle/checks/UniquePropertiesCheck.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheck.java index 5cbab3fe2..e22621a3a 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheck.java @@ -131,21 +131,15 @@ public class UniquePropertiesCheck extends AbstractFileSetCheck { */ private final Multiset duplicatedStrings = HashMultiset .create(); - /** - * Lock for this class to synchronize on - */ - private final Object lock = new Object(); @Override public Object put(Object key, Object value) { - synchronized (lock) { - final Object oldValue = super.put(key, value); - if (oldValue != null && key instanceof String) { - final String keyString = (String) key; - duplicatedStrings.add(keyString); - } - return oldValue; + final Object oldValue = super.put(key, value); + if (oldValue != null && key instanceof String) { + final String keyString = (String) key; + duplicatedStrings.add(keyString); } + return oldValue; } public Multiset getDuplicatedStrings() {