MCPcopy Create free account
hub / github.com/PhantomThief/scope / beginScope

Method beginScope

src/main/java/com/github/phantomthief/scope/Scope.java:160–169  ·  view source on GitHub ↗

正常应该优先使用 #supplyWithNewScope 或者 #runWithNewScope 手工使用beginScope和endScope的场景只有在: 上面两个方法当需要抛出多个正交异常时会造成不必要的try/catch代码 开始scope和结束scope不在一个代码块中 @throws IllegalStateException if try to start a new scope in an exist scope.

()

Source from the content-addressed store, hash-verified

158 * @throws IllegalStateException if try to start a new scope in an exist scope.
159 */
160 @Nonnull
161 public static Scope beginScope() {
162 Scope scope = SCOPE_THREAD_LOCAL.get();
163 if (scope != null) {
164 throw new IllegalStateException("start a scope in an exist scope.");
165 }
166 scope = new Scope();
167 SCOPE_THREAD_LOCAL.set(scope);
168 return scope;
169 }
170
171 /**
172 * @see #beginScope

Callers 15

supplyWithNewScopeMethod · 0.95
initMethod · 0.80
testTimeoutMethod · 0.80
testTimeout2Method · 0.80
testAllTimeoutMethod · 0.80
testMethod · 0.80
testBreakMethod · 0.80
testExceptionMethod · 0.80
testNotHedgeMethod · 0.80
testHedgeMethod · 0.80

Calls 2

getMethod · 0.65
setMethod · 0.65

Tested by 15

initMethod · 0.64
testTimeoutMethod · 0.64
testTimeout2Method · 0.64
testAllTimeoutMethod · 0.64
testMethod · 0.64
testBreakMethod · 0.64
testExceptionMethod · 0.64
testNotHedgeMethod · 0.64
testHedgeMethod · 0.64
testWithEachListenerMethod · 0.64