test_class.declarator: ctx = new HystrixRequestContextRule()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public HystrixRequestContextRule ctx = new HystrixRequestContextRule();
test_class.type: HystrixRequestContextRule
test_class.var_name: ctx
test_class.declarator: uniqueNameCounter = new AtomicInteger(1)
test_class.modifier: static
test_class.original_string: static AtomicInteger uniqueNameCounter = new AtomicInteger(1);
test_class.type: AtomicInteger
test_class.var_name: uniqueNameCounter
test_class.file: hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandTest.java
test_class.identifier: HystrixCommandTest
test_class.superclass: extends CommonHystrixCommandTests<TestHystrixCommand<Integer>>
test_case.body: @Test
      public void testRejectedThreadUsingQueueSize() {
          HystrixCommandKey key = HystrixCommandKey.Factory.asKey("Rejection-B");
          TestCircuitBreaker circuitBreaker = new TestCircuitBreaker();
          SingleThreadedPoolWithQueue pool = new SingleThreadedPoolWithQueue(10, 1);
          // put 1 item in the queue
          // the thread pool won't pick it up because we're bypassing the pool and adding to the queue directly so this will keep the queue full
  
          pool.queue.add(new Runnable() {
  
              @Override
              public void run() {
                  System.out.println("**** queue filler1 ****");
                  try {
                      Thread.sleep(500);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
  
          });
  
  
          TestCommandRejection command = new TestCommandRejection(key, circuitBreaker, pool, 500, 600, TestCommandRejection.FALLBACK_NOT_IMPLEMENTED);
          try {
              // this should fail as we already have 1 in the queue
              command.queue();
              fail("we shouldn't get here");
          } catch (Exception e) {
              e.printStackTrace();
  
              assertTrue(command.isResponseRejected());
              assertFalse(command.isResponseShortCircuited());
              assertFalse(command.isResponseTimedOut());
              assertNotNull(command.getExecutionException());
  
              if (e instanceof HystrixRuntimeException && e.getCause() instanceof RejectedExecutionException) {
                  HystrixRuntimeException de = (HystrixRuntimeException) e;
                  assertNotNull(de.getFallbackException());
                  assertTrue(de.getFallbackException() instanceof UnsupportedOperationException);
                  assertNotNull(de.getImplementingClass());
                  assertNotNull(de.getCause());
                  assertTrue(de.getCause() instanceof RejectedExecutionException);
              } else {
                  fail("the exception should be HystrixRuntimeException with cause as RejectedExecutionException");
              }
          }
  
          assertCommandExecutionEvents(command, HystrixEventType.THREAD_POOL_REJECTED, HystrixEventType.FALLBACK_MISSING);
          assertEquals(0, circuitBreaker.metrics.getCurrentConcurrentExecutionCount());
          assertSaneHystrixRequestLog(1);
      }
test_case.class_method_signature: HystrixCommandTest.testRejectedThreadUsingQueueSize()
test_case.full_signature: @Test public void testRejectedThreadUsingQueueSize()
test_case.identifier: testRejectedThreadUsingQueueSize
test_case.invocations: asKey add println sleep printStackTrace queue fail printStackTrace assertTrue isResponseRejected assertFalse isResponseShortCircuited assertFalse isResponseTimedOut assertNotNull getExecutionException getCause assertNotNull getFallbackException assertTrue getFallbackException assertNotNull getImplementingClass assertNotNull getCause assertTrue getCause fail assertCommandExecutionEvents assertEquals getCurrentConcurrentExecutionCount assertSaneHystrixRequestLog
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRejectedThreadUsingQueueSize()
focal_class.declarator: executionThread = new AtomicReference<Thread>()
focal_class.modifier: private final
focal_class.original_string: private final AtomicReference<Thread> executionThread = new AtomicReference<Thread>();
focal_class.type: AtomicReference<Thread>
focal_class.var_name: executionThread
focal_class.declarator: interruptOnFutureCancel = new AtomicBoolean(false)
focal_class.modifier: private final
focal_class.original_string: private final AtomicBoolean interruptOnFutureCancel = new AtomicBoolean(false);
focal_class.type: AtomicBoolean
focal_class.var_name: interruptOnFutureCancel
focal_class.file: hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java
focal_class.identifier: HystrixCommand
focal_class.interfaces: implements HystrixExecutable<R>, HystrixInvokableInfo<R>, HystrixObservable<R>
focal_class.class_method_signature: HystrixCommand.HystrixCommand(HystrixCommandGroupKey group)
focal_class.full_signature: protected  HystrixCommand(HystrixCommandGroupKey group)
focal_class.identifier: HystrixCommand
focal_class.modifiers: protected
focal_class.parameters: (HystrixCommandGroupKey group)
focal_class.signature:  HystrixCommand(HystrixCommandGroupKey group)
focal_class.class_method_signature: HystrixCommand.HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool)
focal_class.full_signature: protected  HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool)
focal_class.identifier: HystrixCommand
focal_class.modifiers: protected
focal_class.parameters: (HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool)
focal_class.signature:  HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool)
focal_class.class_method_signature: HystrixCommand.HystrixCommand(HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.full_signature: protected  HystrixCommand(HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.identifier: HystrixCommand
focal_class.modifiers: protected
focal_class.parameters: (HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.signature:  HystrixCommand(HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.class_method_signature: HystrixCommand.HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.full_signature: protected  HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.identifier: HystrixCommand
focal_class.modifiers: protected
focal_class.parameters: (HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.signature:  HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.class_method_signature: HystrixCommand.HystrixCommand(Setter setter)
focal_class.full_signature: protected  HystrixCommand(Setter setter)
focal_class.identifier: HystrixCommand
focal_class.modifiers: protected
focal_class.parameters: (Setter setter)
focal_class.signature:  HystrixCommand(Setter setter)
focal_class.class_method_signature: HystrixCommand.HystrixCommand(HystrixCommandGroupKey group, HystrixCommandKey key, HystrixThreadPoolKey threadPoolKey, HystrixCircuitBreaker circuitBreaker, HystrixThreadPool threadPool,
              HystrixCommandProperties.Setter commandPropertiesDefaults, HystrixThreadPoolProperties.Setter threadPoolPropertiesDefaults,
              HystrixCommandMetrics metrics, TryableSemaphore fallbackSemaphore, TryableSemaphore executionSemaphore,
              HystrixPropertiesStrategy propertiesStrategy, HystrixCommandExecutionHook executionHook)
focal_class.full_signature:   HystrixCommand(HystrixCommandGroupKey group, HystrixCommandKey key, HystrixThreadPoolKey threadPoolKey, HystrixCircuitBreaker circuitBreaker, HystrixThreadPool threadPool,
              HystrixCommandProperties.Setter commandPropertiesDefaults, HystrixThreadPoolProperties.Setter threadPoolPropertiesDefaults,
              HystrixCommandMetrics metrics, TryableSemaphore fallbackSemaphore, TryableSemaphore executionSemaphore,
              HystrixPropertiesStrategy propertiesStrategy, HystrixCommandExecutionHook executionHook)
focal_class.identifier: HystrixCommand
focal_class.parameters: (HystrixCommandGroupKey group, HystrixCommandKey key, HystrixThreadPoolKey threadPoolKey, HystrixCircuitBreaker circuitBreaker, HystrixThreadPool threadPool,
              HystrixCommandProperties.Setter commandPropertiesDefaults, HystrixThreadPoolProperties.Setter threadPoolPropertiesDefaults,
              HystrixCommandMetrics metrics, TryableSemaphore fallbackSemaphore, TryableSemaphore executionSemaphore,
              HystrixPropertiesStrategy propertiesStrategy, HystrixCommandExecutionHook executionHook)
focal_class.signature:  HystrixCommand(HystrixCommandGroupKey group, HystrixCommandKey key, HystrixThreadPoolKey threadPoolKey, HystrixCircuitBreaker circuitBreaker, HystrixThreadPool threadPool,
              HystrixCommandProperties.Setter commandPropertiesDefaults, HystrixThreadPoolProperties.Setter threadPoolPropertiesDefaults,
              HystrixCommandMetrics metrics, TryableSemaphore fallbackSemaphore, TryableSemaphore executionSemaphore,
              HystrixPropertiesStrategy propertiesStrategy, HystrixCommandExecutionHook executionHook)
focal_class.class_method_signature: HystrixCommand.run()
focal_class.full_signature: protected abstract R run()
focal_class.identifier: run
focal_class.modifiers: protected abstract
focal_class.parameters: ()
focal_class.return: R
focal_class.signature: R run()
focal_class.class_method_signature: HystrixCommand.getFallback()
focal_class.full_signature: protected R getFallback()
focal_class.identifier: getFallback
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: R
focal_class.signature: R getFallback()
focal_class.class_method_signature: HystrixCommand.getExecutionObservable()
focal_class.full_signature: @Override final protected Observable<R> getExecutionObservable()
focal_class.identifier: getExecutionObservable
focal_class.modifiers: @Override final protected
focal_class.parameters: ()
focal_class.return: Observable<R>
focal_class.signature: Observable<R> getExecutionObservable()
focal_class.class_method_signature: HystrixCommand.getFallbackObservable()
focal_class.full_signature: @Override final protected Observable<R> getFallbackObservable()
focal_class.identifier: getFallbackObservable
focal_class.modifiers: @Override final protected
focal_class.parameters: ()
focal_class.return: Observable<R>
focal_class.signature: Observable<R> getFallbackObservable()
focal_class.class_method_signature: HystrixCommand.execute()
focal_class.full_signature: public R execute()
focal_class.identifier: execute
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: R
focal_class.signature: R execute()
focal_class.class_method_signature: HystrixCommand.queue()
focal_class.full_signature: public Future<R> queue()
focal_class.identifier: queue
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Future<R>
focal_class.signature: Future<R> queue()
focal_class.class_method_signature: HystrixCommand.getFallbackMethodName()
focal_class.full_signature: @Override protected String getFallbackMethodName()
focal_class.identifier: getFallbackMethodName
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getFallbackMethodName()
focal_class.class_method_signature: HystrixCommand.isFallbackUserDefined()
focal_class.full_signature: @Override protected boolean isFallbackUserDefined()
focal_class.identifier: isFallbackUserDefined
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isFallbackUserDefined()
focal_class.class_method_signature: HystrixCommand.commandIsScalar()
focal_class.full_signature: @Override protected boolean commandIsScalar()
focal_class.identifier: commandIsScalar
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean commandIsScalar()
focal_class.superclass: extends AbstractCommand<R>
focal_method.body: public Future<R> queue() {
          /*
           * The Future returned by Observable.toBlocking().toFuture() does not implement the
           * interruption of the execution thread when the "mayInterrupt" flag of Future.cancel(boolean) is set to true;
           * thus, to comply with the contract of Future, we must wrap around it.
           */
          final Future<R> delegate = toObservable().toBlocking().toFuture();
      	
          final Future<R> f = new Future<R>() {
  
              @Override
              public boolean cancel(boolean mayInterruptIfRunning) {
                  if (delegate.isCancelled()) {
                      return false;
                  }
  
                  if (HystrixCommand.this.getProperties().executionIsolationThreadInterruptOnFutureCancel().get()) {
                      /*
                       * The only valid transition here is false -> true. If there are two futures, say f1 and f2, created by this command
                       * (which is super-weird, but has never been prohibited), and calls to f1.cancel(true) and to f2.cancel(false) are
                       * issued by different threads, it's unclear about what value would be used by the time mayInterruptOnCancel is checked.
                       * The most consistent way to deal with this scenario is to say that if *any* cancellation is invoked with interruption,
                       * than that interruption request cannot be taken back.
                       */
                      interruptOnFutureCancel.compareAndSet(false, mayInterruptIfRunning);
          		}
  
                  final boolean res = delegate.cancel(interruptOnFutureCancel.get());
  
                  if (!isExecutionComplete() && interruptOnFutureCancel.get()) {
                      final Thread t = executionThread.get();
                      if (t != null && !t.equals(Thread.currentThread())) {
                          t.interrupt();
                      }
                  }
  
                  return res;
  			}
  
              @Override
              public boolean isCancelled() {
                  return delegate.isCancelled();
  			}
  
              @Override
              public boolean isDone() {
                  return delegate.isDone();
  			}
  
              @Override
              public R get() throws InterruptedException, ExecutionException {
                  return delegate.get();
              }
  
              @Override
              public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
                  return delegate.get(timeout, unit);
              }
          	
          };
  
          /* special handling of error states that throw immediately */
          if (f.isDone()) {
              try {
                  f.get();
                  return f;
              } catch (Exception e) {
                  Throwable t = decomposeException(e);
                  if (t instanceof HystrixBadRequestException) {
                      return f;
                  } else if (t instanceof HystrixRuntimeException) {
                      HystrixRuntimeException hre = (HystrixRuntimeException) t;
                      switch (hre.getFailureType()) {
  					case COMMAND_EXCEPTION:
  					case TIMEOUT:
  						// we don't throw these types from queue() only from queue().get() as they are execution errors
  						return f;
  					default:
  						// these are errors we throw from queue() as they as rejection type errors
  						throw hre;
  					}
                  } else {
                      throw Exceptions.sneakyThrow(t);
                  }
              }
          }
  
          return f;
      }
focal_method.class_method_signature: HystrixCommand.queue()
focal_method.full_signature: public Future<R> queue()
focal_method.identifier: queue
focal_method.invocations: toFuture toBlocking toObservable isCancelled get executionIsolationThreadInterruptOnFutureCancel getProperties compareAndSet cancel get isExecutionComplete get get equals currentThread interrupt isCancelled isDone get get isDone get decomposeException getFailureType sneakyThrow
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: Future<R>
focal_method.signature: Future<R> queue()