Skip to content

Commit

Permalink
synchronized local variables or parameters should be set to final (ap…
Browse files Browse the repository at this point in the history
…ache#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>
  • Loading branch information
slievrly authored and rolandhe committed Sep 9, 2019
1 parent 884dab2 commit 634309e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static Proxy getProxy(ClassLoader cl, Class<?>... ics) {
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<>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public T getExtension(String name) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public void doUnregister(URL url) {
}

@Override
public void doSubscribe(URL url, NotifyListener listener) {
public void doSubscribe(URL url, final NotifyListener listener) {
if (ANY_VALUE.equals(url.getServiceInterface())) {
admin = true;
}
Expand Down Expand Up @@ -324,7 +324,7 @@ protected void registered(URL url) {
}
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcExcept
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();
Expand Down Expand Up @@ -109,7 +109,7 @@ private long getElapsed(Invocation invocation) {
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();
Expand Down

0 comments on commit 634309e

Please sign in to comment.