This patch is missing a unit test for circular reference, which would cause an infinite loop:

```java
  @Rule
  public ExpectedException expectedEx = ExpectedException.none();

  @Test(timeout = 1000)
  public void testRejectsCircularReference() {
    context.putProperty("A", "${B}");
    context.putProperty("B", "${C}");
    context.putProperty("C", "${A}");

    // let's assume OptionHelper is modified to throw an IllegalArgumentException
    expectedEx.expect(IllegalArgumentException.class);
    expectedEx.expectMessage("Circular reference");
    OptionHelper.substVars("${A}", context);
  }
```