Invokes the wrapped Callable's call method, optionally retrying if an
exception occurs. See class documentation for more detail.

@return the return value of the wrapped call() method
328494
public T execute(final Task<T> taskToWrap) throws DevFailed {
        int triesLeft = tries;
        do {
            try {
                return taskToWrap.call();
            } catch (final DevFailed e) {
                triesLeft--;
                // Are we allowed to try again?
                if (triesLeft <= 0) {
                    // No -- throw
                    logger.error("Caught exception, all retries done for error: {}", DevFailedUtils.toString(e));
                    throw e;
                }

                // Yes -- log and allow to loop
                logger.info("Caught exception, retrying... Error was: {}" + DevFailedUtils.toString(e));
                try {
                    Thread.sleep(delay);
                } catch (final InterruptedException e1) {

                }
            }
        } while (triesLeft > 0);
        return null;

    }
239301
@PerformanceSensitive
    public Class<?> getCallerClass(final int depth) {
        if (depth < 0) {
            throw new IndexOutOfBoundsException(Integer.toString(depth));
        }
        // note that we need to add 1 to the depth value to compensate for this method, but not for the Method.invoke
        // since Reflection.getCallerClass ignores the call to Method.invoke()
        try {
            return (Class<?>) GET_CALLER_CLASS.invoke(null, depth + 1 + JDK_7u25_OFFSET);
        } catch (final Exception e) {
            // theoretically this could happen if the caller class were native code
            // TODO: return Object.class
            return null;
        }
    }
1145264
public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable {
        if (thisMethod == null) {
            BeanLogger.LOG.methodHandlerProcessingReturningBeanInstance(self.getClass());
            if (beanInstance == null) {
                throw BeanLogger.LOG.beanInstanceNotSetOnProxy(getBean());
            }
            return beanInstance.getInstance();
        }
        BeanLogger.LOG.methodHandlerProcessingCall(thisMethod, self.getClass());
        if (thisMethod.getDeclaringClass().equals(TargetInstanceProxy.class)) {
            if (beanInstance == null) {
                throw BeanLogger.LOG.beanInstanceNotSetOnProxy(getBean());
            }
            if (thisMethod.getName().equals("weld_getTargetInstance")) {
                return beanInstance.getInstance();
            } else if (thisMethod.getName().equals("weld_getTargetClass")) {
                return beanInstance.getInstanceType();
            } else {
                return null;
            }
        } else if (thisMethod.getName().equals("_initMH")) {
            BeanLogger.LOG.settingNewMethodHandler(args[0], self.getClass());
            return new ProxyMethodHandler(contextId, new TargetBeanInstance(args[0]), getBean());
        } else {
            if (beanInstance == null) {
                throw BeanLogger.LOG.beanInstanceNotSetOnProxy(getBean());
            }
            Object instance = beanInstance.getInstance();
            Object result = beanInstance.invoke(instance, thisMethod, args);
            // if the method returns this and the return type matches the proxy type, return the proxy instead
            // to prevent the bean instance escaping
            if (result != null && result == instance && (thisMethod.getReturnType().isAssignableFrom(self.getClass()))) {
                return self;
            }
            return result;
        }
    }
394438
public static <V> Callable<V> wrap(final Callable<V> callable) {
		final String suffix = Log.suffix.get();
		// t.getCause() is atop t, see Log.concat() for more details
		final Throwable t = new Throwable(Log.throwable.get());
		return new Callable<V>() {
			@Override
			public V call() throws Exception {
				threadNum.incrementAndGet();
				Log.suffix.set(suffix);
				Log.throwable.set(t);
				try {
					return callable.call();
				} catch (Error e) {
					throw new Exception(e);
				} finally {
					Log.throwable.remove();
					Log.suffix.remove();
					threadNum.decrementAndGet();
				}
			}
		};
	}
524823
@Override
    public V call() throws Exception {
        Object captured = capturedRef.get();
        if (captured == null || releaseTtlValueReferenceAfterCall && !capturedRef.compareAndSet(captured, null)) {
            throw new IllegalStateException("TTL value reference is released after call!");
        }

        Object backup = replay(captured);
        try {
            return callable.call();
        } finally {
            restore(backup);
        }
    }
921679
@Override
  public RemoteCallReturn invokeSoapCall(SoapCall<BindingProvider> soapCall) {
    BindingProvider webService = soapCall.getSoapClient();
    RemoteCallReturn.Builder builder = new RemoteCallReturn.Builder();
    synchronized (webService) {
      Object result = null;
      try {
        result = invoke(soapCall);
      } catch (InvocationTargetException e) {
        builder.withException(e.getTargetException());
      } catch (Exception e) {
        builder.withException(e);
      } finally {
        JaxWsSoapContextHandler contextHandler = getContextHandlerFromClient(webService);
        String url = getEndpointAddress(webService);
        builder.withRequestInfo(contextHandler.getLastRequestInfoBuilder().withUrl(url).build());
        builder.withResponseInfo(contextHandler.getLastResponseInfoBuilder().build());
      }
      return builder.withReturnValue(result).build();
    }
  }
1310135
public static Object invokeMethod(Object object, Method method, Object... args) throws Throwable {
        try {
            return method.invoke(object, args);
        } catch (InvocationTargetException e) {
            throw e.getTargetException();
        }
    }
971038
private static RuntimeException cancelThrow(ClientCall<?, ?> call, Throwable t) {
    try {
      call.cancel(null, t);
    } catch (Throwable e) {
      assert e instanceof RuntimeException || e instanceof Error;
      logger.log(Level.SEVERE, "RuntimeException encountered while closing call", e);
    }
    if (t instanceof RuntimeException) {
      throw (RuntimeException) t;
    } else if (t instanceof Error) {
      throw (Error) t;
    }
    // should be impossible
    throw new AssertionError(t);
  }
1258751
protected String[] getCaller() {
        final StackTraceElement[] stack = (new Throwable()).getStackTrace();
        final String loggerClassname = getClass().getName();

        final String callerName;
        final String callerMethod;

        int i = 0;
        while (i < stack.length) {
            final StackTraceElement ste = stack[i];
            final String fc = ste.getClassName();
            if (fc.equals(loggerClassname)) {
                break;
            }

            i++;
        }

        //skip an extra frame... we call ourselves
        i++;

        while (i < stack.length) {
            final StackTraceElement ste = stack[i];
            final String fc = ste.getClassName();
            if (!fc.equals(loggerClassname)) {
                callerMethod = ste.getMethodName();
                callerName = fc;
                return new String[]{callerName, callerMethod};
            }
            i++;
        }
        return new String[]{"", ""};
    }
536909
final synchronized void invoke() {
        result = null;
        exception = null;
        try {
            result = call();
        } catch( Throwable e ) {
            exception = e;
        } finally {
        	done = true;
        }

        // let the calling thread know that we are done.
        notify();
    }
226705
@Override
	public Object invoke(final Invocation invocation) throws Exception {
		if (invocation == null) throw new NullPointerException("invocation");

		MethodDescriptor<?, ?> method = invocation.getMethod();
		DataTypeDescriptor<?> resultd = (DataTypeDescriptor<?>) method.getResult();
		MessageDescriptor<? extends Message> excd = descriptor.getExc();

		RpcRequest request = protocol.getRequest(invocation);
		return session.send(request, resultd, excd);
	}
1069838
public <V> V run(Callable<V> testCallable) throws Exception {
    try {
      beforeRun();
      return testCallable.call();
    } finally {
      afterRun();
      restoreOriginal();
    }
  }
114792
@Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (throwable != null) {
            throw throwable;
        }
        try {
            return invokeInternal(proxy, method, args);
        } catch (Exception e) {
            if (this.throwable != null) {
                logger.debug("exception caught: {} overridden by: {}", e.getMessage(), throwable.getMessage());
                throw throwable;
            } else {
                throw e;
            }
        }
    }
900581
private <T> T executeHttpCallWithRetry(HttpCall<T> call, int runCount) {
    try {
      return call.execute();
    }
    catch (PackageManagerHttpActionException ex) {
      // retry again if configured so...
      if (runCount < props.getRetryCount()) {
        log.info("ERROR: " + ex.getMessage());
        log.debug("HTTP call failed.", ex);
        log.info("---------------");

        StringBuilder msg = new StringBuilder();
        msg.append("HTTP call failed, try again (" + (runCount + 1) + "/" + props.getRetryCount() + ")");
        if (props.getRetryDelaySec() > 0) {
          msg.append(" after " + props.getRetryDelaySec() + " second(s)");
        }
        msg.append("...");
        log.info(msg);
        if (props.getRetryDelaySec() > 0) {
          try {
            Thread.sleep(props.getRetryDelaySec() * DateUtils.MILLIS_PER_SECOND);
          }
          catch (InterruptedException ex1) {
            // ignore
          }
        }
        return executeHttpCallWithRetry(call, runCount + 1);
      }
      else {
        throw ex;
      }
    }
  }
1196682
public function getCallInstance()
    {
        if ($this->callInstance !== false) {
            return $this->callInstance;
        }

        if (is_array($this->call) && isset($this->call[0]) && is_object($this->call[0])) {
            $this->callInstance = $this->call[0];
            return $this->callInstance;
        }

        if (is_object($this->call) && method_exists($this->call, '__invoke')){
            $this->callInstance = $this->call;
            return $this->callInstance;
        }

        if ($this->isFunction() || $this->isStaticMethod()) {
            $this->callInstance = null;
            return $this->callInstance;
        }

        $this->callInstance = $this->resolveCallInstance($this->getCallClass());

        return $this->callInstance;
    }
401328
public static String getCaller() {
		Exception e = new Exception();
		StackTraceElement[] stack = e.getStackTrace();
		if (stack == null || stack.length < 2) return "?";
		// 0 is here, 1 is the caller of this method, 2 is its caller
		return stack[2].getClassName() + "#" + stack[2].getMethodName() + ":" + stack[2].getLineNumber();
	}
149025
public Object getValue()
    {
        if ( value == Special.NULL_VALUE )
            return null;
        if ( value == Special.VOID_TYPE )
                throw new InterpreterError("attempt to unwrap void type");
        return value;
    }