diff --git a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/HeaderUtil.java b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/HeaderUtil.java index 0324278db92ed..4aa5847e58c06 100644 --- a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/HeaderUtil.java +++ b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/headers/HeaderUtil.java @@ -32,7 +32,7 @@ */ @SuppressWarnings({ "rawtypes", "unchecked" }) public class HeaderUtil { - private static final List LANGUAGE_WILDCARD = List.of(Locale.ROOT); + private static final List LANGUAGE_WILDCARD = List.of(new Locale("*")); private static final ClassValue> HEADER_DELEGATE_CACHE = new ClassValue<>() { @Override diff --git a/independent-projects/resteasy-reactive/common/runtime/src/test/java/org/jboss/resteasy/reactive/common/headers/HeaderUtilTest.java b/independent-projects/resteasy-reactive/common/runtime/src/test/java/org/jboss/resteasy/reactive/common/headers/HeaderUtilTest.java new file mode 100644 index 0000000000000..663c9ce99e0ac --- /dev/null +++ b/independent-projects/resteasy-reactive/common/runtime/src/test/java/org/jboss/resteasy/reactive/common/headers/HeaderUtilTest.java @@ -0,0 +1,28 @@ +package org.jboss.resteasy.reactive.common.headers; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.Locale; + +import org.jboss.resteasy.reactive.common.util.MultivaluedTreeMap; +import org.junit.jupiter.api.Test; + +class HeaderUtilTest { + + @Test + void getAcceptableLanguages() { + MultivaluedTreeMap emptyHeaders = new MultivaluedTreeMap<>(); + Locale[] wildcardLocale = new Locale[] { new Locale("*") }; + assertArrayEquals(wildcardLocale, HeaderUtil.getAcceptableLanguages(emptyHeaders).toArray()); + + MultivaluedTreeMap singleLanguage = new MultivaluedTreeMap<>(); + singleLanguage.add("Accept-Language", "de"); + Locale[] singleLocale = new Locale[] { Locale.GERMAN }; + assertArrayEquals(singleLocale, HeaderUtil.getAcceptableLanguages(singleLanguage).toArray()); + + MultivaluedTreeMap multipleWeightedLanguages = new MultivaluedTreeMap<>(); + multipleWeightedLanguages.add("Accept-Language", "da, en-gb;q=0.8, en;q=0.7"); + Locale[] multipleWeightedLocales = new Locale[] { new Locale("da"), Locale.UK, Locale.ENGLISH }; + assertArrayEquals(multipleWeightedLocales, HeaderUtil.getAcceptableLanguages(multipleWeightedLanguages).toArray()); + } +}