Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The SimpleEndpoint class in version 2.10.3 references the URLEncodedUtils class in the wrong library. #998

Closed
AntCode97 opened this issue May 23, 2024 · 2 comments · Fixed by #999
Labels
bug Something isn't working

Comments

@AntCode97
Copy link
Contributor

What is the problem?

https://github.com/opensearch-project/opensearch-java/blob/2.10.3/java-client/src/main/java/org/opensearch/client/transport/endpoints/SimpleEndpoint.java

If you look at the link above, in version 2.10.3, the SimpleEndpoint class imports org.apache.http.client.utils.URLEncodedUtils.

How can one reproduce the problem?

In Spring Boot 3.x, when a request is sent to the Opensearch java client without the org.apache.httpcomponents:httpclient:4.x.x dependency, the SimpleEndpoint cannot get the method of URLEncodedUtils and an error occurs.

Caused by: java.lang.NoSuchMethodError: 'java.lang.String org.apache.http.client.utils.URLEncodedUtils.formatSegments(java.lang.String[])'
	at org.opensearch.client.transport.endpoints.SimpleEndpoint.pathEncode(SimpleEndpoint.java:137) ~[opensearch-java-2.10.0.jar:na]
	at org.opensearch.client.opensearch.core.SearchRequest.lambda$static$2(SearchRequest.java:2293) ~[opensearch-java-2.10.0.jar:na]
	at org.opensearch.client.transport.endpoints.SimpleEndpoint.requestUrl(SimpleEndpoint.java:86) ~[opensearch-java-2.10.0.jar:na]
	at org.opensearch.client.transport.endpoints.DelegatingJsonEndpoint.requestUrl(DelegatingJsonEndpoint.java:55) ~[opensearch-java-2.10.0.jar:na]
	at org.opensearch.client.transport.httpclient5.ApacheHttpClient5Transport.prepareLowLevelRequest(ApacheHttpClient5Transport.java:565) ~[opensearch-java-2.10.0.jar:na]
	at org.opensearch.client.transport.httpclient5.ApacheHttpClient5Transport.performRequestAsync(ApacheHttpClient5Transport.java:169) ~[opensearch-java-2.10.0.jar:na]
	at org.opensearch.client.opensearch.OpenSearchAsyncClient.search(OpenSearchAsyncClient.java:1400) ~[opensearch-java-2.10.0.jar:na]
	at com.kurly.orderreceipt.core.infrastructure.repository.customerfrequentpurchase.CustomerFrequentPurchaseOSRepositoryImpl.aggregateOrderCompleted(CustomerFrequentPurchaseOSRepositoryImpl.kt:104) ~[main/:na]
	at com.kurly.orderreceipt.core.infrastructure.repository.customerfrequentpurchase.CustomerFrequentPurchaseOSRepositoryImpl.aggregateByDealProductNo(CustomerFrequentPurchaseOSRepositoryImpl.kt:68) ~[main/:na]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:351) ~[spring-aop-6.1.4.jar:6.1.4]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196) ~[spring-aop-6.1.4.jar:6.1.4]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-6.1.4.jar:6.1.4]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:765) ~[spring-aop-6.1.4.jar:6.1.4]
...

What do you want us to do?

image

Please improve the part that uses HttpClient so that it can be done without using HttpClient. If there is no immediate alternative, please modify it to use org.apache.hc.core5.net.URLEncodedUtils like the file in the main branch.
https://github.com/opensearch-project/opensearch-java/blob/main/java-client/src/main/java/org/opensearch/client/transport/endpoints/SimpleEndpoint.java

I want to completely remove the org.apache.httpcomponents:httpclient:4.x.x dependency from Spring boot 3.

What is your host/environment?

  • Java 21
  • Spring Boot 3.2.3
  • opensearch-java 2.10.3
@AntCode97 AntCode97 added bug Something isn't working untriaged labels May 23, 2024
@dblock
Copy link
Member

dblock commented May 23, 2024

Makes sense @AntCode97. Care to PR a fix?

@dblock dblock removed the untriaged label May 23, 2024
@AntCode97
Copy link
Contributor Author

Okay. I'll open a pull request as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants