mirror of https://github.com/apache/druid.git
Fix rewrite of queryPath for encoded joda intervals as query param on druid router (#5274)
* Fix rewrite of queryPath for encoded joda intervals as query param on druid router * fix checkstyle * fix comment
This commit is contained in:
parent
61e6878afd
commit
aca200fddb
|
@ -45,6 +45,7 @@ import io.druid.server.router.QueryHostFinder;
|
||||||
import io.druid.server.router.Router;
|
import io.druid.server.router.Router;
|
||||||
import io.druid.server.security.AuthConfig;
|
import io.druid.server.security.AuthConfig;
|
||||||
import io.druid.server.security.Escalator;
|
import io.druid.server.security.Escalator;
|
||||||
|
import org.apache.http.client.utils.URIBuilder;
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.eclipse.jetty.client.api.Request;
|
import org.eclipse.jetty.client.api.Request;
|
||||||
import org.eclipse.jetty.client.api.Response;
|
import org.eclipse.jetty.client.api.Response;
|
||||||
|
@ -58,10 +59,8 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -331,15 +330,15 @@ public class AsyncQueryForwardingServlet extends AsyncProxyServlet implements Qu
|
||||||
protected static URI makeURI(String scheme, String host, String requestURI, String rawQueryString)
|
protected static URI makeURI(String scheme, String host, String requestURI, String rawQueryString)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return new URI(
|
return new URIBuilder()
|
||||||
scheme,
|
.setScheme(scheme)
|
||||||
host,
|
.setHost(host)
|
||||||
requestURI,
|
.setPath(requestURI)
|
||||||
rawQueryString == null ? null : URLDecoder.decode(rawQueryString, "UTF-8"),
|
// No need to encode-decode queryString, it is already encoded
|
||||||
null
|
.setQuery(rawQueryString)
|
||||||
);
|
.build();
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException | URISyntaxException e) {
|
catch (URISyntaxException e) {
|
||||||
log.error(e, "Unable to rewrite URI [%s]", e.getMessage());
|
log.error(e, "Unable to rewrite URI [%s]", e.getMessage());
|
||||||
throw Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,9 @@ import io.druid.server.metrics.NoopServiceEmitter;
|
||||||
import io.druid.server.router.QueryHostFinder;
|
import io.druid.server.router.QueryHostFinder;
|
||||||
import io.druid.server.router.RendezvousHashAvaticaConnectionBalancer;
|
import io.druid.server.router.RendezvousHashAvaticaConnectionBalancer;
|
||||||
import io.druid.server.security.AllowAllAuthorizer;
|
import io.druid.server.security.AllowAllAuthorizer;
|
||||||
import io.druid.server.security.NoopEscalator;
|
|
||||||
import io.druid.server.security.Authorizer;
|
import io.druid.server.security.Authorizer;
|
||||||
import io.druid.server.security.AuthorizerMapper;
|
import io.druid.server.security.AuthorizerMapper;
|
||||||
|
import io.druid.server.security.NoopEscalator;
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.eclipse.jetty.server.Handler;
|
import org.eclipse.jetty.server.Handler;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
@ -308,6 +308,19 @@ public class AsyncQueryForwardingServletTest extends BaseJettyTest
|
||||||
new URI("http://localhost/"),
|
new URI("http://localhost/"),
|
||||||
AsyncQueryForwardingServlet.makeURI("http", "localhost", "/", null)
|
AsyncQueryForwardingServlet.makeURI("http", "localhost", "/", null)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Test reWrite Encoded interval with timezone info
|
||||||
|
// decoded parameters 1900-01-01T00:00:00.000+01.00 -> 1900-01-01T00:00:00.000+01:00
|
||||||
|
Assert.assertEquals(
|
||||||
|
new URI(
|
||||||
|
"http://localhost:1234/some/path?intervals=1900-01-01T00%3A00%3A00.000%2B01%3A00%2F3000-01-01T00%3A00%3A00.000%2B01%3A00"),
|
||||||
|
AsyncQueryForwardingServlet.makeURI(
|
||||||
|
"http",
|
||||||
|
"localhost:1234",
|
||||||
|
"/some/path",
|
||||||
|
"intervals=1900-01-01T00%3A00%3A00.000%2B01%3A00%2F3000-01-01T00%3A00%3A00.000%2B01%3A00"
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestServer implements io.druid.client.selector.Server
|
private static class TestServer implements io.druid.client.selector.Server
|
||||||
|
|
Loading…
Reference in New Issue