public CloseableReference<V> autoClose(boolean value) {
    autoClose.set(value);
    return this;
  }
CloseableReference is a JUnit Rule that provides automated tearDown for an atomic reference. If
the referenced value is an {@code AutoCloseable} or {@code Closeable} then it will be auto-closed
and set to null during tear down.

<p>
If the referenced value is not an {@code AutoCloseable} or {@code Closeable}, the
{@code CloseableReference} will use reflection to invoke any method named {@code close},
{@code disconnect}, or {@code stop} regardless of what interfaces are implemented unless
{@code autoClose} is set to false.

<p>
If the referenced value is null then it will be ignored during tear down.

<p>
In the following example, the test has a {@code ServerLauncher} which will be
auto-stopped and set to null during tear down:

<pre>
{@literal @}Rule
public CloseableReference&lt;ServerLauncher&gt; server = new CloseableReference&lt;&gt;();

{@literal @}Before
public void setUp() throws IOException {
  server.set(new ServerLauncher.Builder()
      .setMemberName("server1")
      .setDisableDefaultServer(true)
      .reinitializeWithWorkingDirectory(temporaryFolder.newFolder("server1").getAbsolutePath())
      .build());

  server.get().start();
}

{@literal @}Test
public void serverHasCache() {
  assertThat(server.get().getCache()).isNotNull();
}
</pre>

<p>
In the following example, the test has a {@code Cache} which will be auto-closed and set to null
during tear down:

<pre>
{@literal @}Rule
public CloseableReference&lt;Cache&gt; cache = new CloseableReference&lt;&gt;();

{@literal @}Before
public void setUp() {
  cache.set(new CacheFactory().create());
}

{@literal @}Test
public void cacheExists() {
  assertThat(cache.get()).isNotNull();
}
</pre>

<p>
In the following example, the test has a {@code DistributedSystem} which will be
auto-disconnected and set to null during tear down:

<pre>
{@literal @}Rule
public CloseableReference&lt;DistributedSystem&gt; system = new CloseableReference&lt;&gt;();

{@literal @}Before
public void setUp() {
  system.set(DistributedSystem.connect());
}

{@literal @}Test
public void distributedSystemExists() {
  assertThat(system.get()).isNotNull();
}
</pre>

<p>
To disable auto-closing in a test, specify {@code autoClose(false)}:

<pre>
{@literal @}Rule
public CloseableReference&lt;ServerLauncher&gt; serverLauncher =
    new CloseableReference&lt;&gt;().autoClose(false);
</pre>

<p>
The {@code CloseableReference} value will still be set to null during tear down even if
auto-closing is disabled.
geode-junit/src/main/java/org/apache/geode/test/junit/rules/CloseableReference.java