Source:
<code>public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { URL url = invoker.getUrl(); String methodName = invocation.getMethodName(); int max = invoker.getUrl().getMethodParameter(methodName, Constants.ACTIVES_KEY, 0); Semaphore activesLimit = null; boolean acquireResult = false; RpcStatus count = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()); if (max > 0) { long timeout = invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.TIMEOUT_KEY, 0); long start = System.currentTimeMillis(); activesLimit = count.getActivesSemaphore(max); try { if(activesLimit != null && !(acquireResult = activesLimit.tryAcquire(timeout,TimeUnit.MILLISECONDS))) { long elapsed = System.currentTimeMillis() - start; <START> int active=count.getActive(); <END> throw new RpcException("Waiting concurrent invoke timeout in client-side for service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", elapsed: " + elapsed + ", timeout: " + timeout + ". concurrent invokes: " + active + ". max concurrent invoke limit: " + max); } } catch (InterruptedException e) { throw new RpcException("Waiting concurrent invoke fail in client-side for service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName()); } } try { long begin = System.currentTimeMillis(); RpcStatus.beginCount(url, methodName); try { Result result = invoker.invoke(invocation); RpcStatus.endCount(url, methodName, System.currentTimeMillis() - begin, true); return result; } catch (RuntimeException t) { RpcStatus.endCount(url, methodName, System.currentTimeMillis() - begin, false); throw t; } } finally { if (max > 0) { if(acquireResult){ activesLimit.release(); } } } }</code><technical_language>need format, too</technical_language>

Target:
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { URL url = invoker.getUrl(); String methodName = invocation.getMethodName(); int max = invoker.getUrl().getMethodParameter(methodName, Constants.ACTIVES_KEY, 0); Semaphore activesLimit = null; boolean acquireResult = false; RpcStatus count = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()); if (max > 0) { long timeout = invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.TIMEOUT_KEY, 0); long start = System.currentTimeMillis(); activesLimit = count.getActivesSemaphore(max); try { if(!(acquireResult = activesLimit.tryAcquire(timeout,TimeUnit.MILLISECONDS))) { long elapsed = System.currentTimeMillis() - start; int active=count.getActive(); throw new RpcException("Waiting concurrent invoke timeout in client-side for service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", elapsed: " + elapsed + ", timeout: " + timeout + ". concurrent invokes: " + active + ". max concurrent invoke limit: " + max); } } catch (InterruptedException e) { throw new RpcException("Waiting concurrent invoke fail in client-side for service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName()); } } try { long begin = System.currentTimeMillis(); RpcStatus.beginCount(url, methodName); try { Result result = invoker.invoke(invocation); RpcStatus.endCount(url, methodName, System.currentTimeMillis() - begin, true); return result; } catch (RuntimeException t) { RpcStatus.endCount(url, methodName, System.currentTimeMillis() - begin, false); throw t; } } finally { if(acquireResult){ activesLimit.release(); } } }