Skip to content

Commit

Permalink
update java 11 src
Browse files Browse the repository at this point in the history
  • Loading branch information
chernser committed Apr 24, 2024
1 parent 6ce419c commit 5d48f52
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.Collections;
import java.io.Serializable;
import java.util.Map;


import com.clickhouse.client.ClickHouseNode;
import com.clickhouse.client.ClickHouseRequest;
Expand All @@ -14,7 +18,13 @@ public final class ClickHouseHttpConnectionFactory {
private static final Logger log = LoggerFactory.getLogger(ClickHouseHttpConnectionFactory.class);

public static ClickHouseHttpConnection createConnection(ClickHouseNode server, ClickHouseRequest<?> request,
ExecutorService executor) throws IOException {
ExecutorService executor) throws IOException
{
return createConnection(server, request, executor, Collections.emptyMap());
}

public static ClickHouseHttpConnection createConnection(ClickHouseNode server, ClickHouseRequest<?> request,
ExecutorService executor, Map<String, Serializable> additionalRequestParams) throws IOException {
HttpConnectionProvider provider = request.getConfig().getOption(ClickHouseHttpOption.CONNECTION_PROVIDER,
HttpConnectionProvider.class);
if (provider == HttpConnectionProvider.APACHE_HTTP_CLIENT) {
Expand All @@ -24,10 +34,10 @@ public static ClickHouseHttpConnection createConnection(ClickHouseNode server, C
log.warn("Error when creating %s, fall back to HTTP_URL_CONNECTION", provider, t);
}
} else if (provider == HttpConnectionProvider.HTTP_CLIENT) {
return new HttpClientConnectionImpl(server, request, executor);
return new HttpClientConnectionImpl(server, request, executor, additionalRequestParams);
}

return new HttpUrlConnectionImpl(server, request, executor);
return new HttpUrlConnectionImpl(server, request, executor, additionalRequestParams);
}

private ClickHouseHttpConnectionFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
import java.io.Serializable;
import java.util.Map;

import javax.net.ssl.SSLContext;

Expand Down Expand Up @@ -173,9 +175,9 @@ private HttpRequest newRequest(String url) {
.timeout(Duration.ofMillis(config.getSocketTimeout())).build();
}

protected HttpClientConnectionImpl(ClickHouseNode server, ClickHouseRequest<?> request, ExecutorService executor)
throws IOException {
super(server, request);
protected HttpClientConnectionImpl(ClickHouseNode server, ClickHouseRequest<?> request, ExecutorService executor,
Map<String, Serializable> additionalParams) throws IOException {
super(server, request, additionalParams);

HttpClient.Builder builder = HttpClient.newBuilder().version(Version.HTTP_1_1)
.connectTimeout(Duration.ofMillis(config.getConnectionTimeout())).followRedirects(Redirect.NORMAL);
Expand Down
2 changes: 0 additions & 2 deletions clickhouse-jdbc/src/main/javacc/ClickHouseSqlParser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ public class ClickHouseSqlParser {
for (int i = anyArgsListStart; i < stmtLength; i++) {
char ch = token_source.builder.charAt(i);
if (ch == '"' && isQuoted ) {
roles.add(roleBuff.toString());
roleBuff.setLength(0);
isQuoted = false;
} else if (ch == '"') {
isQuoted = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private static Object[][] setRolesArgsForTestSetRole() {
HttpConnectionProvider.APACHE_HTTP_CLIENT.name()},
{new String[]{"ROL1", "\"ROL2,☺\""}, "set role \"ROL2,☺\", ROL1", new String[]{"ROL2,☺", "ROL1"},
HttpConnectionProvider.APACHE_HTTP_CLIENT.name()},
{new String[]{"ROL1", "ROL2"}, "set role ROL2 , ROL1, ", new String[]{"ROL", "ROL1"},
{new String[]{"ROL1", "ROL2"}, "set role ROL2 , ROL1 ", new String[]{"ROL2", "ROL1"},
HttpConnectionProvider.APACHE_HTTP_CLIENT.name()},
};
}
Expand Down

0 comments on commit 5d48f52

Please sign in to comment.