This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 1cfca0d978 NIFI-10036: Corrected Elasticsearch Client Service to
prefix paths for all requests
1cfca0d978 is described below
commit 1cfca0d978322ef5b42d8128d88f41031cf025ad
Author: Joe Gresock <[email protected]>
AuthorDate: Thu May 19 10:44:59 2022 -0400
NIFI-10036: Corrected Elasticsearch Client Service to prefix paths for all
requests
- Prefixing endpoint paths with a forward slash ensures correct HTTP
request formatting required for some deployments with a forwarding proxy
This closes #6058
Signed-off-by: David Handermann <[email protected]>
---
.../nifi/elasticsearch/ElasticSearchClientServiceImpl.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git
a/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientServiceImpl.java
b/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientServiceImpl.java
index 58dc99ea52..2f2ae2a1a2 100644
---
a/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientServiceImpl.java
+++
b/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientServiceImpl.java
@@ -320,7 +320,7 @@ public class ElasticSearchClientServiceImpl extends
AbstractControllerService im
final HttpEntity entity = new NStringEntity(payload.toString(),
ContentType.APPLICATION_JSON);
final StopWatch watch = new StopWatch();
watch.start();
- final Response response = performRequest("POST", "_bulk",
requestParameters, entity);
+ final Response response = performRequest("POST", "/_bulk",
requestParameters, entity);
watch.stop();
final String rawResponse =
IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
@@ -360,7 +360,7 @@ public class ElasticSearchClientServiceImpl extends
AbstractControllerService im
final HttpEntity entity = new NStringEntity(sb.toString(),
ContentType.APPLICATION_JSON);
final StopWatch watch = new StopWatch();
watch.start();
- final Response response = performRequest("POST", "_bulk",
requestParameters, entity);
+ final Response response = performRequest("POST", "/_bulk",
requestParameters, entity);
watch.stop();
if (getLogger().isDebugEnabled()) {
@@ -406,7 +406,7 @@ public class ElasticSearchClientServiceImpl extends
AbstractControllerService im
try {
final StringBuilder endpoint = new StringBuilder();
if (StringUtils.isNotBlank(index) && !"/".equals(index)) {
- endpoint.append(index);
+ endpoint.append("/").append(index);
}
endpoint.append("/_refresh");
final Response response = performRequest("POST",
endpoint.toString(), requestParameters, null);
@@ -421,7 +421,7 @@ public class ElasticSearchClientServiceImpl extends
AbstractControllerService im
public Map<String, Object> get(final String index, final String type,
final String id, final Map<String, String> requestParameters) {
try {
final StringBuilder endpoint = new StringBuilder();
- endpoint.append(index);
+ endpoint.append("/").append(index);
if (StringUtils.isNotBlank(type)) {
endpoint.append("/").append(type);
} else {
@@ -482,7 +482,7 @@ public class ElasticSearchClientServiceImpl extends
AbstractControllerService im
put("keep_alive", keepAlive);
}
}};
- final Response response = performRequest("POST", index + "/_pit",
params, null);
+ final Response response = performRequest("POST", "/" + index +
"/_pit", params, null);
final String body =
IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
parseResponseWarningHeaders(response);