From b3cdb2790c6c44de87fe5aa97c2dc4f917ba5948 Mon Sep 17 00:00:00 2001 From: Kan Tang Date: Tue, 26 Jan 2021 17:43:22 -0800 Subject: [PATCH] Uses std::abort() instead of abort() or exception for precondition. (#1474) --- .../src/datalake_file_client.cpp | 5 +++-- .../test/datalake_file_client_test.cpp | 4 ---- .../src/share_file_client.cpp | 14 +++++++------- .../test/share_file_client_test.cpp | 3 --- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp index 5b01a97bd..d445c40b3 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp @@ -233,7 +233,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { if (options.ContentHash.HasValue() && options.ContentHash.GetValue().Algorithm != HashAlgorithm::Md5) { - abort(); + std::abort(); } protocolLayerOptions.ContentMd5 = options.ContentHash; protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; @@ -424,7 +424,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { protocolLayerOptions.ExpiryOrigin = expiryOrigin; if (options.ExpiresOn.HasValue() && options.TimeToExpireInMs.HasValue()) { - throw std::runtime_error("ExpiresOn and TimeToExpireInMs should be mutually exlusive."); + // ExpiresOn and TimeToExpireInMs should be mutually exlusive. + std::abort(); } if (options.ExpiresOn.HasValue()) { diff --git a/sdk/storage/azure-storage-files-datalake/test/datalake_file_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/datalake_file_client_test.cpp index c49b1eec0..256472231 100644 --- a/sdk/storage/azure-storage-files-datalake/test/datalake_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/datalake_file_client_test.cpp @@ -471,10 +471,6 @@ namespace Azure { namespace Storage { namespace Test { Files::DataLake::ScheduleDataLakeFileExpiryOriginType::Absolute, options), StorageException); options.ExpiresOn = "Tue, 29 Sep 2100 09:53:03 GMT"; - EXPECT_THROW( - client.ScheduleDeletion( - Files::DataLake::ScheduleDataLakeFileExpiryOriginType::Absolute, options), - std::runtime_error); options.TimeToExpireInMs = Azure::Core::Nullable(); EXPECT_NO_THROW(client.ScheduleDeletion( Files::DataLake::ScheduleDataLakeFileExpiryOriginType::Absolute, options)); diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp index ac98196d2..677653ed0 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp @@ -180,7 +180,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { if (options.HttpHeaders.ContentHash.Algorithm != HashAlgorithm::Md5) { - abort(); + std::abort(); } protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; } @@ -346,9 +346,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - throw std::runtime_error( - "FilePermission or FilePermissionKey must be set if FilePermissionCopyMode is set to " - "PermissionCopyModeType::Override."); + // FilePermission or FilePermissionKey must be set if FilePermissionCopyMode is set to + // PermissionCopyModeType::Override. + std::abort(); } } } @@ -478,7 +478,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { if (options.TransactionalContentHash.HasValue() && options.TransactionalContentHash.GetValue().Algorithm != HashAlgorithm::Md5) { - abort(); + std::abort(); } protocolLayerOptions.ContentMd5 = options.TransactionalContentHash; protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; @@ -891,7 +891,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { if (options.HttpHeaders.ContentHash.Algorithm != HashAlgorithm::Md5) { - abort(); + std::abort(); } protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; } @@ -991,7 +991,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { if (options.HttpHeaders.ContentHash.Algorithm != HashAlgorithm::Md5) { - abort(); + std::abort(); } protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; } diff --git a/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp index 426833533..e98d1fb3e 100644 --- a/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp @@ -652,9 +652,6 @@ namespace Azure { namespace Storage { namespace Test { auto destFileClient = m_shareClient->GetRootDirectoryClient().GetFileClient(LowercaseRandomString(10)); - Files::Shares::StartCopyShareFileOptions copyOptions; - copyOptions.PermissionCopyMode = Files::Shares::Models::PermissionCopyModeType::Override; - EXPECT_THROW(destFileClient.StartCopy(fileClient.GetUrl(), copyOptions), std::runtime_error); } }