code: public <T> T resolveFuture(final Future<T> future, final boolean autocancel) throws RuntimeException
  	{
  		while (isValid() && !future.isCancelled())
  		{
  			try
  			{
  				return future.get(getTimeLeft(), TimeUnit.MILLISECONDS);
  			}
  			catch (InterruptedException e)
  			{
  				// ignore and start waiting again
  			}
  			catch (ExecutionException e)
  			{
  				try
  				{
  					if (autocancel)
  						future.cancel(true);
  				}
  				catch (Throwable t)
  				{
  					log.info("{resolveFuture} Error auto-cancelling after ExecutionException: " + t.getMessage(), t);
  				}
  
  				throw new RuntimeException(e);
  			}
  			catch (TimeoutException e)
  			{
  				break;
  			}
  		}
  
  		// We timed out
  		future.cancel(true);
  		return null;
  	}
docs: Resolves a Future, potentially automatically cancelling it in the event of a timeout / failure
  
  @param <T>
  the return type
  @param future
  @param autocancel
  if the thread should be cancelled if the deadline expires within this method
  
  @return the resolved value of the future (or null in the event of a timeout)
  
  @throws RuntimeException
  if the operation fails (or is cancelled by another party)