synchronized local variables or parameters should be set to final (#4325)

* synchronized local variables or parameters should be set to final
Signed-off-by: slievrly <slievrly@163.com>
* remove unused import
Signed-off-by: slievrly <slievrly@163.com>
This commit is contained in:
jimin 2019-06-27 15:01:45 +08:00 committed by Huxing Zhang
parent a970480294
commit 52bef8117b
4 changed files with 6 additions and 6 deletions

View File

@ -102,7 +102,7 @@ public abstract class Proxy {
String key = sb.toString();
// get cache by class loader.
Map<String, Object> cache;
final Map<String, Object> cache;
synchronized (PROXY_CACHE_MAP) {
cache = PROXY_CACHE_MAP.computeIfAbsent(cl, k -> new HashMap<>());
}

View File

@ -342,7 +342,7 @@ public class ExtensionLoader<T> {
if ("true".equals(name)) {
return getDefaultExtension();
}
Holder<Object> holder = getOrCreateHolder(name);
final Holder<Object> holder = getOrCreateHolder(name);
Object instance = holder.get();
if (instance == null) {
synchronized (holder) {

View File

@ -263,7 +263,7 @@ public class MulticastRegistry extends FailbackRegistry {
}
@Override
public void doSubscribe(URL url, NotifyListener listener) {
public void doSubscribe(URL url, final NotifyListener listener) {
if (ANY_VALUE.equals(url.getServiceInterface())) {
admin = true;
}
@ -324,7 +324,7 @@ public class MulticastRegistry extends FailbackRegistry {
}
urls.add(url);
List<URL> list = toList(urls);
for (NotifyListener listener : entry.getValue()) {
for (final NotifyListener listener : entry.getValue()) {
notify(key, listener, list);
synchronized (listener) {
listener.notify();

View File

@ -57,7 +57,7 @@ public class ActiveLimitFilter extends ListenableFilter {
URL url = invoker.getUrl();
String methodName = invocation.getMethodName();
int max = invoker.getUrl().getMethodParameter(methodName, ACTIVES_KEY, 0);
RpcStatus rpcStatus = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName());
final RpcStatus rpcStatus = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName());
if (!RpcStatus.beginCount(url, methodName, max)) {
long timeout = invoker.getUrl().getMethodParameter(invocation.getMethodName(), TIMEOUT_KEY, 0);
long start = System.currentTimeMillis();
@ -109,7 +109,7 @@ public class ActiveLimitFilter extends ListenableFilter {
return StringUtils.isNotEmpty(beginTime) ? System.currentTimeMillis() - Long.parseLong(beginTime) : 0;
}
private void notifyFinish(RpcStatus rpcStatus, int max) {
private void notifyFinish(final RpcStatus rpcStatus, int max) {
if (max > 0) {
synchronized (rpcStatus) {
rpcStatus.notifyAll();