use of org.apache.beam.sdk.util.ThrowingSupplier in project beam by apache.
the class AwsModuleTest method withSystemPropertyOverrides.
private <T> T withSystemPropertyOverrides(Properties overrides, ThrowingSupplier<T> fun) throws Exception {
Properties systemProps = System.getProperties();
Properties previousProps = new Properties();
systemProps.entrySet().stream().filter(e -> overrides.containsKey(e.getKey())).forEach(e -> previousProps.put(e.getKey(), e.getValue()));
overrides.forEach(systemProps::put);
try {
return fun.get();
} finally {
overrides.forEach(systemProps::remove);
previousProps.forEach(systemProps::put);
}
}
Aggregations