Code review comment: There is also a case to be made for using `getEnvVarOrProperty` here, but let's be cautious and only broaden the scope a little instead of all the way

Code before review:
public Result get() {
StartupLogCompressor compressor = new StartupLogCompressor("Checking Docker Environment", Optional.empty(), null,
(s) -> s.getName().startsWith("ducttape"));
try {
Class<?> dockerClientFactoryClass = Thread.currentThread().getContextClassLoader()
.loadClass("org.testcontainers.DockerClientFactory");
Object dockerClientFactoryInstance = dockerClientFactoryClass.getMethod("instance").invoke(null);
Class<?> configurationClass = Thread.currentThread().getContextClassLoader()
.loadClass("org.testcontainers.utility.TestcontainersConfiguration");
Object configurationInstance = configurationClass.getMethod("getInstance").invoke(null);
String oldReusePropertyValue = (String) configurationClass
.getMethod("getEnvVarOrUserProperty", String.class, String.class)
.invoke(configurationInstance, "testcontainers.reuse.enable", "false");
Method updateUserConfigMethod = configurationClass.getMethod("updateUserConfig", String.class, String.class);
updateUserConfigMethod.invoke(configurationInstance, "testcontainers.reuse.enable", "true");
boolean isAvailable = (boolean) dockerClientFactoryClass.getMethod("isDockerAvailable")
.invoke(dockerClientFactoryInstance);
if (!isAvailable) {
compressor.closeAndDumpCaptured();
}
updateUserConfigMethod.invoke(configurationInstance, "testcontainers.reuse.enable", oldReusePropertyValue);
return isAvailable ? Result.AVAILABLE : Result.UNAVAILABLE;
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
if (!silent) {
compressor.closeAndDumpCaptured();
LOGGER.debug("Unable to use Testcontainers to determine if Docker is working", e);
}
return Result.UNKNOWN;
} finally {
compressor.close();
}
}

Line under review: .getMethod("getEnvVarOrUserProperty", String.class, String.class)

Code after addressing the review:
public Result get() {
StartupLogCompressor compressor = new StartupLogCompressor("Checking Docker Environment", Optional.empty(), null,
(s) -> s.getName().startsWith("ducttape"));
try {
Class<?> dockerClientFactoryClass = Thread.currentThread().getContextClassLoader()
.loadClass("org.testcontainers.DockerClientFactory");
Object dockerClientFactoryInstance = dockerClientFactoryClass.getMethod("instance").invoke(null);
Class<?> configurationClass = Thread.currentThread().getContextClassLoader()
.loadClass("org.testcontainers.utility.TestcontainersConfiguration");
Object configurationInstance = configurationClass.getMethod("getInstance").invoke(null);
String oldReusePropertyValue = (String) configurationClass
.getMethod("getEnvVarOrUserProperty", String.class, String.class)
.invoke(configurationInstance, "testcontainers.reuse.enable", "false");
Method updateUserConfigMethod = configurationClass.getMethod("updateUserConfig", String.class, String.class);
updateUserConfigMethod.invoke(configurationInstance, "testcontainers.reuse.enable", "true");
boolean isAvailable = (boolean) dockerClientFactoryClass.getMethod("isDockerAvailable")
.invoke(dockerClientFactoryInstance);
if (!isAvailable) {
compressor.closeAndDumpCaptured();
}
updateUserConfigMethod.invoke(configurationInstance, "testcontainers.reuse.enable", oldReusePropertyValue);
return isAvailable ? Result.AVAILABLE : Result.UNAVAILABLE;
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
if (!silent) {
compressor.closeAndDumpCaptured();
LOGGER.debug("Unable to use Testcontainers to determine if Docker is working", e);
}
return Result.UNKNOWN;
} finally {
compressor.close();
}
}