From 3a42176e0c0da1be6cd98cd2ee126a8961daf867 Mon Sep 17 00:00:00 2001 From: Al Niessner Date: Wed, 24 Jul 2024 11:25:04 -0700 Subject: [PATCH] Fixes the problem but leaves a landmine Using apache 5 first fixes the problem because it does encoding correctly, However, if it is not in the classpath then what was once though fixed will break. So, not a fix so much as a minor paving over a gaping hole. Signed-off-by: Al Niessner --- .../java/org/opensearch/client/util/PathEncoder.java | 4 ++++ .../client/opensearch/model/EndpointTest.java | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/java-client/src/main/java/org/opensearch/client/util/PathEncoder.java b/java-client/src/main/java/org/opensearch/client/util/PathEncoder.java index c9345a003f..b10d8955b2 100644 --- a/java-client/src/main/java/org/opensearch/client/util/PathEncoder.java +++ b/java-client/src/main/java/org/opensearch/client/util/PathEncoder.java @@ -31,7 +31,11 @@ public class PathEncoder { static { Class clazz = null; try { +<<<<<<< Updated upstream // Try Apache HttpClient5 first since this is a default one +======= + // Try Apache HttpClient5 first since this is the "better" encoder +>>>>>>> Stashed changes clazz = Class.forName(HTTP_CLIENT5_UTILS_CLASS); } catch (final ClassNotFoundException ex) { try { diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/model/EndpointTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/model/EndpointTest.java index b37f98622a..5f6d05c59d 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/model/EndpointTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/model/EndpointTest.java @@ -57,6 +57,7 @@ public void testArrayPathParameter() { assertEquals("/a/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); req = RefreshRequest.of(b -> b.index("a", "b")); +<<<<<<< Updated upstream if (isHttpClient5Present()) { assertEquals("/a%2Cb/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); @@ -70,6 +71,12 @@ public void testArrayPathParameter() { } else { assertEquals("/a,b,c/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); } +======= + assertEquals("/a%2Cb/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); + + req = RefreshRequest.of(b -> b.index("a", "b", "c")); + assertEquals("/a%2Cb%2Cc/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); +>>>>>>> Stashed changes } @Test @@ -80,11 +87,15 @@ public void testPathEncoding() { assertEquals("/a%2Fb/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); req = RefreshRequest.of(b -> b.index("a/b", "c/d")); +<<<<<<< Updated upstream if (isHttpClient5Present()) { assertEquals("/a%2Fb%2Cc%2Fd/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); } else { assertEquals("/a%2Fb,c%2Fd/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); } +======= + assertEquals("/a%2Fb%2Cc%2Fd/_refresh", RefreshRequest._ENDPOINT.requestUrl(req)); +>>>>>>> Stashed changes }