When switching the channel, AbstractRetryEntryPoint rebuilds the URL from its decoded parts.
So, when switching on a URL, that containes a special character (like '?'), which is encoded according to RFC 3986, it changes the URL.
For example, the URL "/foo%3Fbar.html", where "%3F" encodes the "?", becomes "/foo?bar.html", which is not encoded correctly, thus resulting in a 404-Error.
Encoding the rebuild URL would not work, becaus all special characters (like contained slashes for example) would be encoded than, which is, as far as I know, not correct.
I fixed the issue in my local git repository by calling the UrlUtils, which were fixed in issue
SEC-1255, for building the redirect URL.
I will apply my patch to this bug-report.