Skip to content

Commit 9ef5ca2

Browse files
committed
move initiation and feature flag check to ConnImpl
1 parent a829daa commit 9ef5ca2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

clickhouse-jdbc/src/main/java/com/clickhouse/jdbc/ClickHouseDriver.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public class ClickHouseDriver implements Driver {
4242

4343
static final java.util.logging.Logger parentLogger = java.util.logging.Logger.getLogger("com.clickhouse.jdbc");
4444

45-
static String frameworksDetected = null;
45+
public static String frameworksDetected = null;
4646

47-
private static class FrameworksDetection {
47+
public static class FrameworksDetection {
4848
private static final List<String> FRAMEWORKS_TO_DETECT = List.of("apache.spark");
4949
static volatile String frameworksDetected = null;
5050

@@ -134,8 +134,6 @@ public static Map<ClickHouseOption, Serializable> toClientOptions(Properties pro
134134
options.put(o, ClickHouseOption.fromString(e.getValue().toString(), o.getValueType()));
135135
}
136136
}
137-
if (frameworksDetected != null)
138-
options.put(ClickHouseClientOption.PRODUCT_NAME, frameworksDetected);
139137
return options;
140138
}
141139

@@ -172,8 +170,6 @@ public ClickHouseConnection connect(String url, Properties info) throws SQLExcep
172170
if (!acceptsURL(url)) {
173171
return null;
174172
}
175-
if (!url.toLowerCase().contains("disable-frameworks-detection"))
176-
frameworksDetected = FrameworksDetection.getFrameworksDetected();
177173

178174
log.debug("Creating connection");
179175
return new ClickHouseConnectionImpl(url, info);

clickhouse-jdbc/src/main/java/com/clickhouse/jdbc/internal/ClickHouseConnectionImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,11 @@ public ClickHouseConnectionImpl(String url, Properties properties) throws SQLExc
291291
public ClickHouseConnectionImpl(ConnectionInfo connInfo) throws SQLException {
292292
Properties props = connInfo.getProperties();
293293
jvmTimeZone = TimeZone.getDefault();
294-
294+
if (props.get("disable_frameworks_detection") == null || !props.get("disable_frameworks_detection").toString().equalsIgnoreCase("true")) {
295+
ClickHouseDriver.frameworksDetected = ClickHouseDriver.FrameworksDetection.getFrameworksDetected();
296+
if (ClickHouseDriver.frameworksDetected != null)
297+
props.setProperty(ClickHouseClientOption.PRODUCT_NAME.getKey(), props.getProperty(ClickHouseClientOption.PRODUCT_NAME.getKey()) + ClickHouseDriver.frameworksDetected);
298+
}
295299
ClickHouseClientBuilder clientBuilder = ClickHouseClient.builder()
296300
.options(ClickHouseDriver.toClientOptions(props))
297301
.defaultCredentials(connInfo.getDefaultCredentials());

0 commit comments

Comments
 (0)