Fix UriPathEncoder bug to improve performance

Fix `isAllowed` check and write test to ensure that additional object
instances are not created unnecessarily.

See gh-40615
This commit is contained in:
Phillip Webb
2024-05-03 12:29:41 -07:00
parent d0ce4daec1
commit 8a72e55106
2 changed files with 7 additions and 1 deletions

View File

@@ -36,7 +36,7 @@ final class UriPathEncoder {
static String encode(String path) {
byte[] bytes = path.getBytes(StandardCharsets.UTF_8);
for (byte b : bytes) {
if (isAllowed(b)) {
if (!isAllowed(b)) {
return encode(bytes);
}
}