From fd0ddd5afa153518bb1a1b60794bcb100e49c722 Mon Sep 17 00:00:00 2001 From: Dominik Przybysz <132913826+sfc-gh-dprzybysz@users.noreply.github.com> Date: Tue, 5 Nov 2024 07:25:09 +0100 Subject: [PATCH] SNOW-1786156: Replace raw asserts with exceptions (#1953) --- .../client/jdbc/SnowflakeFileTransferAgent.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeFileTransferAgent.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeFileTransferAgent.java index 895275cef..ce289e90b 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeFileTransferAgent.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeFileTransferAgent.java @@ -925,11 +925,13 @@ private void parseCommand() throws SnowflakeSQLException { // get source file locations as array (apply to both upload and download) JsonNode locationsNode = jsonNode.path("data").path("src_locations"); + if (!locationsNode.isArray()) { + throw new SnowflakeSQLException( + queryID, ErrorCode.INTERNAL_ERROR, "src_locations must be an array"); + } queryID = jsonNode.path("data").path("queryId").asText(); - assert locationsNode.isArray(); - String[] src_locations; try { @@ -1459,7 +1461,13 @@ public static List getFileTransferMetadatas( } // For UPLOAD we expect encryptionMaterial to have length 1 - assert encryptionMaterial.size() == 1; + if (encryptionMaterial.size() != 1) { + throw new SnowflakeSQLException( + queryId, + ErrorCode.INTERNAL_ERROR, + "Encryption material for UPLOAD should have size 1 but have " + + encryptionMaterial.size()); + } final Set sourceFiles = expandFileNames(srcLocations, queryId);