Skip to content

Commit

Permalink
Avoid using lambda in PropertiesConfigSource (#1279)
Browse files Browse the repository at this point in the history
This shouldn't make a difference in the real world,
but those method handles sure don't look nice in
flamegraphs
  • Loading branch information
geoand authored Jan 5, 2025
1 parent 84378da commit 2bcff37
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.net.URL;
import java.util.Map;
import java.util.Properties;
import java.util.function.Consumer;

import io.smallrye.common.classloader.ClassPathUtils;
import io.smallrye.config.common.utils.ConfigSourceUtil;
Expand Down Expand Up @@ -74,11 +76,14 @@ public PropertiesConfigSource(Properties properties, String name, int defaultOrd
public static Map<String, ConfigValue> urlToConfigValueMap(URL locationOfProperties, String name, int ordinal)
throws IOException {
ConfigValueProperties properties = new ConfigValueProperties(name, ordinal);
ClassPathUtils.consumeStream(locationOfProperties, inputStream -> {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, UTF_8))) {
properties.load(reader);
} catch (IOException e) {
throw new UncheckedIOException(e);
ClassPathUtils.consumeStream(locationOfProperties, new Consumer<>() {
@Override
public void accept(InputStream inputStream) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, UTF_8))) {
properties.load(reader);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
});
return properties;
Expand Down

0 comments on commit 2bcff37

Please sign in to comment.