docs: @SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.EmptyCatchBlock" })
      @RequestHandler(priority = 990, dynamic = true)
      public void onRequest(Request.In event) {
          @SuppressWarnings("PMD.AccessorClassGeneration")
          final Selection selection = event.associated(Session.class)
              .map(session -> (Selection) session.computeIfAbsent(
                  Selection.class, newKey -> new Selection(cookieName, path)))
              .orElseGet(() -> new Selection(cookieName, path));
          selection.setCurrentEvent(event);
          event.setAssociated(Selection.class, selection);
          if (selection.isExplicitlySet()) {
              return;
          }
  
          // Try to get locale from cookies
          final HttpRequest request = event.httpRequest();
          Optional<String> localeNames = request.findValue(
              HttpField.COOKIE, Converters.COOKIE_LIST)
              .flatMap(cookieList -> cookieList.valueForName(cookieName));
          if (localeNames.isPresent()) {
              try {
                  List<Locale> cookieLocales = LOCALE_LIST
                      .fromFieldValue(localeNames.get());
                  if (!cookieLocales.isEmpty()) {
                      Collections.reverse(cookieLocales);
                      cookieLocales.stream()
                          .forEach(locale -> selection.prefer(locale));
                      return;
                  }
              } catch (ParseException e) {
                  // Unusable
              }
          }
  
          // Last resport: Accept-Language header field
          Optional<List<ParameterizedValue<Locale>>> accepted = request.findValue(
              HttpField.ACCEPT_LANGUAGE, Converters.LANGUAGE_LIST);
          if (accepted.isPresent()) {
              Locale[] locales = accepted.get().stream()
                  .sorted(ParameterizedValue.WEIGHT_COMPARATOR)
                  .map(value -> value.value()).toArray(Locale[]::new);
              selection.updateFallbacks(locales);
          }
      }