Skip to content

Null SSLSocket causes NPE when jdbc url contains "ssl=true" #2206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kslex opened this issue Mar 10, 2025 · 3 comments · Fixed by #2304
Closed

Null SSLSocket causes NPE when jdbc url contains "ssl=true" #2206

kslex opened this issue Mar 10, 2025 · 3 comments · Fixed by #2304
Assignees
Labels
Milestone

Comments

@kslex
Copy link

kslex commented Mar 10, 2025

Describe the bug

The DummySSLConnectionSocketFactory creates a null SSLSocket because initSslContext in HttpAPIClientHelper#createHttpClient is false.
The root cause is that JdbcConfiguration does not read the ssl property from jdbc url.

Steps to reproduce

  1. set dependency version between 0.8.0 to 0.8.2
  2. set jdbc url like: jdbc:clickhouse://localhost:8123/testdb?ssl=true

Expected behaviour

SSLSocket not null

Code example

url: jdbc:clickhouse://localhost:8123/testdb?ssl=true
username: xxx
password: xxx
driver-class-name: com.clickhouse.jdbc.ClickHouseDriver

<dependency>
    <groupId>com.clickhouse</groupId>
    <artifactId>clickhouse-jdbc</artifactId>
    <version>0.8.0</version>
</dependency>

Error log

Caused by: java.lang.NullPointerException: SSL Socket
java.base/java.util.Objects.requireNonNull(Objects.java:259)
org.apache.hc.core5.util.Args.notNull(Args.java:165)
org.apache.hc.core5.http.impl.io.SocketHolder.(SocketHolder.java:58)
org.apache.hc.client5.http.impl.io.DefaultManagedHttpClientConnection.bind(DefaultManagedHttpClientConnection.java:188)
org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:232)
org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:490)
org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:164)
org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:174)
org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:144)
org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192)
org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:150)
org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:113)
org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:110)
org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:174)
org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:87)
org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:55)
org.apache.hc.client5.http.classic.HttpClient.executeOpen(HttpClient.java:183)
com.clickhouse.client.api.internal.HttpAPIClientHelper.executeRequest(HttpAPIClientHelper.java:423)

Configuration

Environment

  • Client version: 0.8.0 - 0.8.2
  • Language version: jdk21
  • OS: win11
@kslex kslex added the bug label Mar 10, 2025
kslex added a commit to kslex/clickhouse-java that referenced this issue Apr 2, 2025
@kslex kslex mentioned this issue Apr 2, 2025
1 task
@chernser
Copy link
Contributor

chernser commented Apr 7, 2025

Good day, @kslex !
Thank you for reporting the issue!

@Paultagoras Paultagoras added this to the 0.8.4 milestone Apr 8, 2025
mzitnik added a commit that referenced this issue Apr 13, 2025
@mzitnik mzitnik mentioned this issue Apr 13, 2025
4 tasks
mzitnik added a commit that referenced this issue Apr 13, 2025
@Sameerlaag
Copy link

Sameerlaag commented Apr 16, 2025

Would anybody got a workaround while waiting for the fix to be released ?

@kslex
Copy link
Author

kslex commented Apr 18, 2025

Would anybody got a workaround while waiting for the fix to be released ?

try setting this in the client properties instead of jdbc url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants