Returns a {@link Callable} object that, when
called, runs the given privileged exception action and returns
its result.
@param action the privileged exception action to run
@return a callable object
@throws NullPointerException if action null
353960
public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) {
        if (action == null)
            throw new NullPointerException();
        return new Callable<Object>() {
            public Object call() throws Exception { return action.run(); }};
    }
481007
public static <T> T
        doPrivileged(PrivilegedExceptionAction<T> action)
        throws PrivilegedActionException {
        try {
            return action.run();
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new PrivilegedActionException(e);
        }
    }
992228
private Object executeMethod(final Method method, final ServletContextImpl context, final Object[] params)
            throws PrivilegedActionException, IllegalAccessException, InvocationTargetException {

        if (SecurityUtil.isPackageProtectionEnabled()) {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                public Object run() throws IllegalAccessException, InvocationTargetException {
                    return method.invoke(context, params);
                }
            });
        } else {
            return method.invoke(context, params);
        }
    }
612599
public static RuntimeException rethrow(RequestExecutionException e) throws UnavailableException, TimedOutException
    {
        if (e instanceof RequestTimeoutException)
            throw toThrift((RequestTimeoutException)e);
        else
            throw new UnavailableException();
    }
265202
public Api getActionResult(String action, String params) throws Exception {
    Api result = this.getActionResult(action, params, null, null);
    return result;
  }
553022
public static <T> T doAs(final Subject subject,
         final java.security.PrivilegedExceptionAction<T> action)
         throws java.security.PrivilegedActionException {
      Stack<Subject> stack = SUBJECT.get();
      if (stack == null) {
         stack = new Stack<>();
         SUBJECT.set(stack);
      }
      stack.push(subject);
      try {
         return action.run();
      } catch (Exception e) {
         throw new PrivilegedActionException(e);
      } finally {
         stack.pop();
         if (stack.isEmpty()) {
            SUBJECT.remove();
         }
      }
   }
934624
public function each(callable $action = null)
    {
        if ($action === null) {
            $each = call_user_func($this->each);
            if (!self::isIterable($each)) {
                throw new \RuntimeException("return value is not iterable object");
            }
            return $each;
        } else {
            $this->apply($action);
        }

        return null;
    }
68122
public static <Result> TaskBuilder<Result> create(Callable<Result> action) {
        return new TaskBuilder<Result>().action(action);
    }
1247881
private function executeAction(string $action)
    {
        list($controller, $method) = explode('@', $action);

        $class = '\App\Controllers\\'.ucfirst($controller).'Controller';

        if (!class_exists($class)) {
            throw new ExceptionHandler('Class "'.$class.'" not found.');
        }

        $controllerInstantiate = new $class();

        if (!method_exists($controllerInstantiate, $method)) {
            throw new ExceptionHandler('Method "'.$method.'" not found in '.$class.'.');
        }

        return call_user_func_array([new $controllerInstantiate, $method], []);
    }
761578
@Override
    public String action(EntityActionOperation entityActionOperation)
            throws ServiceException {
        try {
            return service.action(entityActionOperation);
        } catch (UniformInterfaceException e) {
            throw processCatch(new ServiceException(e));
        } catch (ClientHandlerException e) {
            throw processCatch(new ServiceException(e));
        }
    }
717554
public JMenuItem add(UserInterfaceAction action)
	{
		try
		{
			Method _specializedMethod = getClass().getMethod(FUNCTION_NAME_ADD, new Class[]
			{
				action.getClass()
			});
			return (JMenuItem) _specializedMethod.invoke(this, new Object[]
			{
				action
			});
		}
		catch (Exception _exception)
		{
			_exception.printStackTrace(System.err);
			return null;
		}
	}
611644
protected void onError(Action action, Throwable t) {
        Console.error(Console.CONSTANTS.lastActionError(), t.getMessage());
    }
387811
public static <T> Callable<T> privilegedCallable(Callable<T> callable) {
        if (callable == null)
            throw new NullPointerException();
        return callable;
    }
1363790
private void handleActionException(String target, HttpServletRequest request, HttpServletResponse response, Action action, ActionException e) {
		int errorCode = e.getErrorCode();
		String msg = null;
		if (errorCode == 404) {
			msg = "404 Not Found: ";
		} else if (errorCode == 400) {
			msg = "400 Bad Request: ";
		} else if (errorCode == 401) {
			msg = "401 Unauthorized: ";
		} else if (errorCode == 403) {
			msg = "403 Forbidden: ";
		}
		
		if (msg != null) {
			if (log.isWarnEnabled()) {
				String qs = request.getQueryString();
				msg = msg + (qs == null ? target : target + "?" + qs);
				if (e.getMessage() != null) {
					msg = msg + "\n" + e.getMessage();
				}
				log.warn(msg);
			}
		} else {
			if (log.isErrorEnabled()) {
				String qs = request.getQueryString();
				log.error(errorCode + " Error: " + (qs == null ? target : target + "?" + qs), e);
			}
		}
		
		e.getErrorRender().setContext(request, response, action.getViewPath()).render();
	}
1212054
@Override
    public Object invoke(Object controller, String action) throws Throwable {
        if(action == null) action = this.defaultActionName;
        ActionInvoker handle = actions.get(action);
        if(handle == null) throw new IllegalArgumentException("Invalid action name: " + action);
        return handle.invoke(controller);
    }
1284770
public final void batchUpdateWidget(final Runnable action) {
        _batchUpdateCounter++;
        try {
            action.run();
        } catch (final RuntimeException e) {
            logger.error("Exception occurred in widget batch update, fireValueChanged() will not be invoked", e);
            throw e;
        } finally {
            _batchUpdateCounter--;
        }
        if (_batchUpdateCounter == 0) {
            onBatchFinished();
        }
    }
216275
public <T> T execute(final Callable<T> callable) throws Exception {
        int attempts = 0;
        int maxAttempts = retryPolicy.getMaxAttempts();
        long delay = retryPolicy.getDelay();
        TimeUnit timeUnit = retryPolicy.getTimeUnit();
        while(attempts < maxAttempts) {
            try {
                attempts++;
                beforeCall();
                T result = callable.call();
                afterCall(result);
                return result;
            } catch (Exception e) {
                onException(e);
                if (attempts >= maxAttempts) {
                    onMaxAttempts(e);
                    throw e;
                }
                beforeWait();
                sleep(timeUnit.toMillis(delay));
                afterWait();
            }
        }
        return null;
    }