Q:

Overriding Hystrix command properties specified in .properties file

I need to override command timeout property specified in my application.properties file. Here is what I tried 
    @Test
    public void testTokenQueryTimeout() throws Exception
    {
      String propertyToSet ="hystrix.command.quickbaseTokenQueryCommand.execution.isolation.thread.timeoutInMilliseconds";
      String prop="";
      try {
        prop = ConfigurationManager.getConfigInstance().getProperty(
            propertyToSet).toString();
        logger.info("\n\n\noriginal quickbaseTokenQueryCommand timeout ="+prop);

        System.setProperty(
            propertyToSet,"10");

        prop = ConfigurationManager.getConfigInstance().getProperty(
            propertyToSet).toString();
        logger.info("\n\n\nupdated quickbaseTokenQueryCommand timeout ="+prop);

        String response = accountValidation.isValidToken(token);
        logger.info(response);
        Assert.assertFalse(true);
      }
      catch (AccountValidationServiceException e)
      {
        Assert.assertTrue(Constants.ERRCODE_TOKEN_QUERY_TIMED_OUT.equals(e.getErrorCode()));
      }
      finally {
        ConfigurationManager.getConfigInstance().clearProperty(propertyToSet);
        System.clearProperty(propertyToSet);
        if(!GeneralUtil.isObjectEmpty(System.getProperty(
            propertyToSet)))prop = System.getProperty(
            propertyToSet);

        logger.info("Updated testTokenQueryTimeout timeout ="+prop);
      }
    }

Notice, System.setProperty(propertyToSet,"10"). With this approach this test case passes i.e. the property gets changed and command times out but another test case fails due to this command timeout though I am clearing the property from System.
I also tried setting the property using ConfigurationManager.getConfigInstance().setProperty(
                propertyToSet).toString(),"10"); But in that case, this change of property has no effect and command does not timeout.
Is there something I am missing here.
Please help.

A:

Try using the ConcurrentCompositeConfiguration class
application.properties
hystrix.command.HelloWorldCommand.execution.isolation.thread.timeoutInMilliseconds=200

Command
public class HelloWorldCommand extends HystrixCommand<String> {

  public HelloWorldCommand() {
    super(HystrixCommandGroupKey.Factory.asKey("HelloWorldGroup"));
  }

  @Override
  protected String run() throws Exception {
    TimeUnit.MILLISECONDS.sleep(1100);
    return "Hello";
  }
}

Test
public class HelloWorldCommandTest {

  @Test
  public void commandConfigTest() {
    String propertyKey = "hystrix.command.HelloWorldCommand.execution.isolation.thread.timeoutInMilliseconds";
    ConcurrentCompositeConfiguration config = (ConcurrentCompositeConfiguration) ConfigurationManager.getConfigInstance();

    Integer originalTimeout = (Integer) config.getProperty(propertyKey);
    config.setOverrideProperty(propertyKey, 1200);
    String result = new HelloWorldCommand().execute();
    assertThat(result, is("Hello"));

    config.setOverrideProperty(propertyKey, originalTimeout);
    Integer timeoutValue = (Integer) config.getProperty(propertyKey);
    assertThat(timeoutValue, is(originalTimeout));
  }
}

