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

improve comment

上级 9f570712
......@@ -34,8 +34,7 @@ public final class MtContextCallable<V> implements Callable<V> {
final Map<String, Object> old = mtContext.get();
try {
mtContext.set(context);
V ret = callable.call();
return ret;
return callable.call();
} finally {
mtContext.set(old); // restore MtContext
}
......@@ -47,6 +46,8 @@ public final class MtContextCallable<V> implements Callable<V> {
/**
* Factory method, wrapper input {@link Callable} to {@link MtContextCallable}.
* <p/>
* This method is idempotent.
*
* @param callable input {@link Callable}
* @return Wrapped {@link Callable}
......@@ -56,7 +57,7 @@ public final class MtContextCallable<V> implements Callable<V> {
throw new NullPointerException("input argument is null!");
}
if (callable instanceof MtContextCallable) {
if (callable instanceof MtContextCallable) { // avoid redundant decoration, and ensure idempotency
return (MtContextCallable<T>) callable;
}
return new MtContextCallable<T>(callable);
......
......@@ -47,6 +47,8 @@ public final class MtContextRunnable implements Runnable {
/**
* Factory method, wrapper input {@link Runnable} to {@link MtContextRunnable}.
* <p/>
* This method is idempotent.
*
* @param runnable input {@link Runnable}
* @return Wrapped {@link Runnable}
......@@ -56,7 +58,7 @@ public final class MtContextRunnable implements Runnable {
throw new NullPointerException("input argument is null!");
}
if (runnable instanceof MtContextRunnable) {
if (runnable instanceof MtContextRunnable) { // avoid redundant decoration, and ensure idempotency
return (MtContextRunnable) runnable;
}
return new MtContextRunnable(runnable);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册