Skip to content

Conversation

@astefan
Copy link
Contributor

@astefan astefan commented Jul 23, 2019

URI.resolve() method doesn't work as we intended it to work and when an URI of the form http://localhost:8080/custom_path/ is being used (common in reverse proxy scenarios), the resolve("/_sql") (very common path resolve) call will strip the custom_path from the URI and just put /_sql instead. Whereas the desired behavior should be appending the additional segment to the existent URI and creating the http://localhost:8080/custom_path/_sql URI.

This PR fixes #44721.

@astefan
Copy link
Contributor Author

astefan commented Jul 23, 2019

@elasticmachine run elasticsearch-ci/packaging-sample

Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

For completeness I would add a test with null segment and tests with null and empty uri.

concatenatedPath = path + "/" + cleanSegment;
}
try {
return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), concatenatedPath,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using new URI(concatenatedPath) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because concatenatedPath is only the uri.getPath() section of the initial URI. If one has http://localhost:9200/es_rest/ path is /es_rest/. And this method's purpose is to add a new segment to the already existent path: http://localhost:9200/es_rest/ + /_sql for example.

@astefan astefan merged commit 06dea85 into elastic:master Jul 25, 2019
@astefan astefan deleted the 44721_fix branch July 25, 2019 07:26
astefan added a commit that referenced this pull request Jul 25, 2019
astefan added a commit that referenced this pull request Jul 25, 2019
astefan added a commit that referenced this pull request Jul 25, 2019
astefan added a commit that referenced this pull request Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL JDBC and CLI fails when ES hosted under path

4 participants