Skip to content

Commit ac106a9

Browse files
APPS-53008: Enable SnowflakeFileTransferAgent deep tests with mockStatic of StorageClientFactory.getFactory
1 parent 464540d commit ac106a9

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/main/java/net/snowflake/client/jdbc/SnowflakeFileTransferAgent.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ public class SnowflakeFileTransferAgent extends SFBaseFileTransferAgent {
8080
private static final SFLogger logger =
8181
SFLoggerFactory.getLogger(SnowflakeFileTransferAgent.class);
8282

83-
static final StorageClientFactory storageFactory = StorageClientFactory.getFactory();
84-
8583
private static final ObjectMapper mapper = ObjectMapperFactory.getObjectMapper();
8684

8785
// We will allow buffering of upto 128M data before spilling to disk during
@@ -891,7 +889,8 @@ public SnowflakeFileTransferAgent(String command, SFSession session, SFStatement
891889
parseCommand();
892890

893891
if (stageInfo.getStageType() != StageInfo.StageType.LOCAL_FS) {
894-
storageClient = storageFactory.createClient(stageInfo, parallel, null, session);
892+
storageClient =
893+
StorageClientFactory.getFactory().createClient(stageInfo, parallel, null, session);
895894
}
896895
}
897896

@@ -1627,7 +1626,8 @@ private void uploadStream() throws SnowflakeSQLException {
16271626
fileMetadata,
16281627
(stageInfo.getStageType() == StageInfo.StageType.LOCAL_FS)
16291628
? null
1630-
: storageFactory.createClient(stageInfo, parallel, encMat, session),
1629+
: StorageClientFactory.getFactory()
1630+
.createClient(stageInfo, parallel, encMat, session),
16311631
session,
16321632
command,
16331633
sourceStream,
@@ -1728,7 +1728,7 @@ public InputStream downloadStream(String fileName) throws SnowflakeSQLException
17281728
RemoteStoreFileEncryptionMaterial encMat = srcFileToEncMat.get(sourceLocation);
17291729
String presignedUrl = srcFileToPresignedUrl.get(sourceLocation);
17301730

1731-
return storageFactory
1731+
return StorageClientFactory.getFactory()
17321732
.createClient(stageInfo, parallel, encMat, session)
17331733
.downloadToStream(
17341734
session,
@@ -1772,7 +1772,8 @@ private void downloadFiles() throws SnowflakeSQLException {
17721772
fileMetadataMap,
17731773
(stageInfo.getStageType() == StageInfo.StageType.LOCAL_FS)
17741774
? null
1775-
: storageFactory.createClient(stageInfo, parallel, encMat, session),
1775+
: StorageClientFactory.getFactory()
1776+
.createClient(stageInfo, parallel, encMat, session),
17761777
session,
17771778
command,
17781779
parallel,
@@ -1878,8 +1879,8 @@ private void uploadFiles(Set<String> fileList, int parallel) throws SnowflakeSQL
18781879
fileMetadata,
18791880
(stageInfo.getStageType() == StageInfo.StageType.LOCAL_FS)
18801881
? null
1881-
: storageFactory.createClient(
1882-
stageInfo, parallel, encryptionMaterial.get(0), session),
1882+
: StorageClientFactory.getFactory()
1883+
.createClient(stageInfo, parallel, encryptionMaterial.get(0), session),
18831884
session,
18841885
command,
18851886
null,
@@ -2174,7 +2175,8 @@ private static void pushFileToRemoteStore(
21742175
(ArgSupplier)
21752176
() -> (encMat == null ? "NULL" : encMat.getSmkId() + "|" + encMat.getQueryId()));
21762177

2177-
StorageObjectMetadata meta = storageFactory.createStorageMetadataObj(stage.getStageType());
2178+
StorageObjectMetadata meta =
2179+
StorageClientFactory.getFactory().createStorageMetadataObj(stage.getStageType());
21782180
meta.setContentLength(uploadSize);
21792181
if (digest != null) {
21802182
initialClient.addDigestMetadata(meta, digest);
@@ -2312,7 +2314,7 @@ public static void uploadWithoutConnection(SnowflakeFileTransferConfig config) t
23122314
uploadSize);
23132315

23142316
SnowflakeStorageClient initialClient =
2315-
storageFactory.createClient(stageInfo, 1, encMat, /* session= */ null);
2317+
StorageClientFactory.getFactory().createClient(stageInfo, 1, encMat, /* session= */ null);
23162318

23172319
// Normal flow will never hit here. This is only for testing purposes
23182320
if (isInjectedFileTransferExceptionEnabled()) {
@@ -2428,7 +2430,8 @@ private static void pushFileToRemoteStoreWithPresignedUrl(
24282430
(ArgSupplier)
24292431
() -> (encMat == null ? "NULL" : encMat.getSmkId() + "|" + encMat.getQueryId()));
24302432

2431-
StorageObjectMetadata meta = storageFactory.createStorageMetadataObj(stage.getStageType());
2433+
StorageObjectMetadata meta =
2434+
StorageClientFactory.getFactory().createStorageMetadataObj(stage.getStageType());
24322435
meta.setContentLength(uploadSize);
24332436
if (digest != null) {
24342437
initialClient.addDigestMetadata(meta, digest);

0 commit comments

Comments
 (0)