docs: @SuppressWarnings("unused")
      final void handleQueryParameters(ByteBuffer buffer, ParseState state, HttpServerExchange exchange) throws BadRequestException {
          StringBuilder stringBuilder = state.stringBuilder;
          int queryParamPos = state.pos;
          int mapCount = state.mapCount;
          boolean urlDecodeRequired = state.urlDecodeRequired;
          String nextQueryParam = state.nextQueryParam;
  
          //so this is a bit funky, because it not only deals with parsing, but
          //also deals with URL decoding the query parameters as well, while also
          //maintaining a non-decoded version to use as the query string
          //In most cases these string will be the same, and as we do not want to
          //build up two separate strings we don't use encodedStringBuilder unless
          //we encounter an encoded character
  
          while (buffer.hasRemaining()) {
              char next = (char) (buffer.get() & 0xFF);
              if(!allowUnescapedCharactersInUrl && !ALLOWED_TARGET_CHARACTER[next]) {
                  throw new BadRequestException(UndertowMessages.MESSAGES.invalidCharacterInRequestTarget(next));
              }
              if (next == ' ' || next == '\t') {
                  final String queryString = stringBuilder.toString();
                  exchange.setQueryString(queryString);
                  if (nextQueryParam == null) {
                      if (queryParamPos != stringBuilder.length()) {
                          exchange.addQueryParam(decode(stringBuilder.substring(queryParamPos), urlDecodeRequired, state, true, true), "");
                      }
                  } else {
                      exchange.addQueryParam(nextQueryParam, decode(stringBuilder.substring(queryParamPos), urlDecodeRequired, state, true, true));
                  }
                  state.state = ParseState.VERSION;
                  state.stringBuilder.setLength(0);
                  state.pos = 0;
                  state.nextQueryParam = null;
                  state.urlDecodeRequired = false;
                  state.mapCount = 0;
                  return;
              } else if (next == '\r' || next == '\n') {
                  throw UndertowMessages.MESSAGES.failedToParsePath();
              } else {
                  if (decode && (next == '+' || next == '%' || next > 127)) { //+ is only a whitespace substitute in the query part of the URL
                      urlDecodeRequired = true;
                  } else if (next == '=' && nextQueryParam == null) {
                      nextQueryParam = decode(stringBuilder.substring(queryParamPos), urlDecodeRequired, state, true, true);
                      urlDecodeRequired = false;
                      queryParamPos = stringBuilder.length() + 1;
                  } else if (next == '&' && nextQueryParam == null) {
                      if (++mapCount >= maxParameters) {
                          throw UndertowMessages.MESSAGES.tooManyQueryParameters(maxParameters);
                      }
                      if (queryParamPos != stringBuilder.length()) {
                          exchange.addQueryParam(decode(stringBuilder.substring(queryParamPos), urlDecodeRequired, state, true, true), "");
                      }
                      urlDecodeRequired = false;
                      queryParamPos = stringBuilder.length() + 1;
                  } else if (next == '&') {
                      if (++mapCount >= maxParameters) {
                          throw UndertowMessages.MESSAGES.tooManyQueryParameters(maxParameters);
                      }
                      exchange.addQueryParam(nextQueryParam, decode(stringBuilder.substring(queryParamPos), urlDecodeRequired, state, true, true));
                      urlDecodeRequired = false;
                      queryParamPos = stringBuilder.length() + 1;
                      nextQueryParam = null;
                  }
                  stringBuilder.append(next);
  
              }
  
          }
          state.pos = queryParamPos;
          state.nextQueryParam = nextQueryParam;
          state.urlDecodeRequired = urlDecodeRequired;
          state.mapCount = mapCount;
      }