Skip to content

Commit 5a3650a

Browse files
sfc-gh-ggengclaude
andcommitted
[SNOW-3249917] JDBC removal Step 11a (part 2): Replicate HttpUtil, swap callers to replicated REST infrastructure
Replicate JDBC's HttpUtil as JdbcHttpUtil (renamed to avoid collision with ingest's existing net.snowflake.ingest.utils.HttpUtil). Also replicate SnowflakeMutableProxyRoutePlanner and AttributeEnhancingHttpRequestRetryHandler as small helper classes. Key changes: - JdbcHttpUtil: verbatim replication of JDBC HttpUtil with import swaps. SFTrustManager replaced with null (ingest does not use OCSP trust manager). SFSSLConnectionSocketFactory -> IngestSSLConnectionSocketFactory. SystemUtil.convertSystemPropertyToIntValue inlined. SessionUtil.isNewRetryStrategyRequest inlined as static method. Deprecated S3 proxy wrapper methods omitted (S3HttpUtil callable directly). - RestRequest: all FQN net.snowflake.client.core.HttpUtil references replaced with JdbcHttpUtil. SessionUtil.isNewRetryStrategyRequest replaced with JdbcHttpUtil.isNewRetryStrategyRequest. - TelemetryClient: HttpUtil.executeGeneralRequest and HttpUtil.getSocketTimeout replaced with JdbcHttpUtil equivalents. SnowflakeSQLException import swapped to ingest's replicated version. - SnowflakeGCSClient: HttpUtil.getHttpClient, getHttpClientWithoutDecompression, getSocketTimeout replaced with JdbcHttpUtil equivalents. Added toIngestKey adapter to convert JDBC's HttpClientSettingsKey during transition. - SnowflakeAzureClient: setSessionlessProxyForAzure import swapped from JDBC HttpUtil to JdbcHttpUtil. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 72e1169 commit 5a3650a

File tree

8 files changed

+1327
-23
lines changed

8 files changed

+1327
-23
lines changed

.plans/JDBC_REMOVAL_PLAN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ eliminate the JDBC dependency entirely.
1212

1313
**This project is a pure mechanical migration. There must be no functional changes.**
1414

15+
- **Always replicate** — no matter how many dependencies, replicate the JDBC original
16+
verbatim. Never create "simplified replacements" or "minimal viable alternatives."
1517
- Copy JDBC classes verbatim into this repo. Compare against the actual source file
1618
in the JDBC repo (not decompiled output). Do not refactor, simplify, rename fields,
1719
change method signatures, strip comments/Javadoc, or improve logic — even where

src/main/java/net/snowflake/ingest/connection/telemetry/TelemetryClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import java.util.LinkedList;
1212
import java.util.Objects;
1313
import java.util.concurrent.Future;
14-
import net.snowflake.client.core.HttpUtil;
15-
import net.snowflake.client.jdbc.SnowflakeSQLException;
14+
import net.snowflake.ingest.streaming.internal.fileTransferAgent.JdbcHttpUtil;
1615
import net.snowflake.ingest.streaming.internal.fileTransferAgent.ObjectMapperFactory;
16+
import net.snowflake.ingest.streaming.internal.fileTransferAgent.SnowflakeSQLException;
1717
import net.snowflake.ingest.streaming.internal.fileTransferAgent.TelemetryThreadPool;
1818
import net.snowflake.ingest.streaming.internal.fileTransferAgent.log.SFLogger;
1919
import net.snowflake.ingest.streaming.internal.fileTransferAgent.log.SFLoggerFactory;
@@ -275,11 +275,11 @@ private boolean sendBatch() throws IOException {
275275

276276
try {
277277
response =
278-
HttpUtil.executeGeneralRequest(
278+
JdbcHttpUtil.executeGeneralRequest(
279279
post,
280280
TELEMETRY_HTTP_RETRY_TIMEOUT_IN_SEC,
281281
0,
282-
(int) HttpUtil.getSocketTimeout().toMillis(),
282+
(int) JdbcHttpUtil.getSocketTimeout().toMillis(),
283283
0,
284284
this.httpClient);
285285
stopwatch.stop();
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Replicated from snowflake-jdbc (v3.25.1)
3+
* Source: https://github.com/snowflakedb/snowflake-jdbc/blob/v3.25.1/src/main/java/net/snowflake/client/core/AttributeEnhancingHttpRequestRetryHandler.java
4+
*
5+
* Permitted differences: package declaration.
6+
*/
7+
package net.snowflake.ingest.streaming.internal.fileTransferAgent;
8+
9+
import java.io.IOException;
10+
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
11+
import org.apache.http.protocol.HttpContext;
12+
13+
/**
14+
* Extends {@link DefaultHttpRequestRetryHandler} to store the current execution count (attempt
15+
* number) in the {@link HttpContext}. This allows interceptors to identify retry attempts.
16+
*
17+
* <p>The execution count is stored using the key defined by {@link #EXECUTION_COUNT_ATTRIBUTE}.
18+
*/
19+
class AttributeEnhancingHttpRequestRetryHandler extends DefaultHttpRequestRetryHandler {
20+
/**
21+
* The key used to store the current execution count (attempt number) in the {@link HttpContext}.
22+
* Interceptors can use this key to retrieve the count. The value stored will be an {@link
23+
* Integer}.
24+
*/
25+
static final String EXECUTION_COUNT_ATTRIBUTE = "net.snowflake.client.core.execution-count";
26+
27+
@Override
28+
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
29+
context.setAttribute(EXECUTION_COUNT_ATTRIBUTE, executionCount);
30+
return super.retryRequest(exception, executionCount, context);
31+
}
32+
}

0 commit comments

Comments
 (0)