提交 f96869af 编写于 作者: oldratlee's avatar oldratlee 🔥

clean code

上级 0b352cfc
package com.alibaba.mtc; package com.alibaba.mtc;
import java.lang.ref.WeakReference;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
...@@ -84,7 +82,7 @@ public class MtContextThreadLocal<T> extends InheritableThreadLocal<T> { ...@@ -84,7 +82,7 @@ public class MtContextThreadLocal<T> extends InheritableThreadLocal<T> {
}; };
void addMtContextThreadLocal() { void addMtContextThreadLocal() {
if(!holder.get().containsKey(this)) { if (!holder.get().containsKey(this)) {
holder.get().put(this, null); holder.get().put(this, null);
} }
} }
...@@ -95,8 +93,7 @@ public class MtContextThreadLocal<T> extends InheritableThreadLocal<T> { ...@@ -95,8 +93,7 @@ public class MtContextThreadLocal<T> extends InheritableThreadLocal<T> {
static Map<MtContextThreadLocal<?>, Object> copy() { static Map<MtContextThreadLocal<?>, Object> copy() {
Map<MtContextThreadLocal<?>, Object> copy = new HashMap<MtContextThreadLocal<?>, Object>(); Map<MtContextThreadLocal<?>, Object> copy = new HashMap<MtContextThreadLocal<?>, Object>();
for (Iterator<MtContextThreadLocal<?>> iterator = holder.get().keySet().iterator(); iterator.hasNext(); ) { for (MtContextThreadLocal<?> threadLocal : holder.get().keySet()) {
MtContextThreadLocal<?> threadLocal = iterator.next();
copy.put(threadLocal, threadLocal.copyMtContextValue()); copy.put(threadLocal, threadLocal.copyMtContextValue());
} }
return copy; return copy;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册