Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for multiple values of a key in a Config file - apache#9102, apache#12689 #12799

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,7 +21,6 @@
import com.google.common.base.Preconditions;
import java.io.File;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -161,10 +160,10 @@ public static Map<String, Object> toMap(Configuration configuration) {
}

private static Object mapValue(String key, Configuration configuration) {
// For multi-value config, convert it to a single comma connected string value.
// For multi-value config, override it with the last seen value
// For single-value config, return its raw property, unless it needs interpolation.
return Optional.of(configuration.getStringArray(key)).filter(values -> values.length > 1)
.<Object>map(values -> Arrays.stream(values).collect(Collectors.joining(","))).orElseGet(() -> {
.<Object>map(values -> values[values.length - 1]).orElseGet(() -> {
Object rawProperty = configuration.getProperty(key);
if (!needInterpolate(rawProperty)) {
return rawProperty;
Expand Down