/**
  * Executes a Psr\Http\Message\RequestInterface and (if applicable) automatically retries
  * when errors occur.
  *
  * @param Google_Client $client
  * @param Psr\Http\Message\RequestInterface $req
  * @return array decoded result
  * @throws Google_Service_Exception on server side error (ie: not authenticated,
  *  invalid or malformed post body, invalid url)
  */
 public static function execute(ClientInterface $client, RequestInterface $request, $expectedClass = null, $config = array(), $retryMap = null)
 {
     $runner = new Google_Task_Runner($config, sprintf('%s %s', $request->getMethod(), (string) $request->getUri()), array(get_class(), 'doExecute'), array($client, $request, $expectedClass));
     if (!is_null($retryMap)) {
         $runner->setRetryMap($retryMap);
     }
     return $runner->run();
 }
 /**
  * Runs the defined task.
  *
  * @return mixed
  */
 private function runTask()
 {
     $task = new Google_Task_Runner($this->retryConfig, '', array($this, 'runNextTask'));
     if (null !== $this->retryMap) {
         $task->setRetryMap($this->retryMap);
     }
     $exception = $this->getMockBuilder('Google_Service_Exception')->setMethods(array('setTraceOptions'))->disableOriginalConstructor()->getMock();
     $exceptionCount = 0;
     $exceptionCalls = array();
     for ($i = 0; $i < $this->mockedCallsCount; $i++) {
         if (is_int($this->mockedCalls[$i])) {
             $exceptionCalls[$exceptionCount++] = $this->mockedCalls[$i];
             $this->mockedCalls[$i] = $exception;
         }
     }
     $task->setRetryMap($exceptionCalls);
     return $task->run();
 }