diff --git a/implementation/src/main/java/io/smallrye/config/ProfileConfigSourceInterceptor.java b/implementation/src/main/java/io/smallrye/config/ProfileConfigSourceInterceptor.java index 6def94f33..fada40e5d 100644 --- a/implementation/src/main/java/io/smallrye/config/ProfileConfigSourceInterceptor.java +++ b/implementation/src/main/java/io/smallrye/config/ProfileConfigSourceInterceptor.java @@ -9,13 +9,19 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.function.IntFunction; import jakarta.annotation.Priority; +import org.eclipse.microprofile.config.spi.Converter; + @Priority(Priorities.LIBRARY + 200) public class ProfileConfigSourceInterceptor implements ConfigSourceInterceptor { private static final long serialVersionUID = -6305289277993917313L; + private static final Converter> PROFILES_CONVERTER = newCollectionConverter( + newTrimmingConverter(STRING_CONVERTER), new ArrayListFactory()); + private final List profiles; private final List prefixProfiles; @@ -138,7 +144,15 @@ public static String activeName(final String name, final List profiles) } public static List convertProfile(final String profile) { - List profiles = newCollectionConverter(newTrimmingConverter(STRING_CONVERTER), ArrayList::new).convert(profile); + List profiles = PROFILES_CONVERTER.convert(profile); return profiles != null ? profiles : Collections.emptyList(); } + + private static class ArrayListFactory implements IntFunction> { + + @Override + public ArrayList apply(int value) { + return new ArrayList(value); + } + } }