This is an automated email from the ASF dual-hosted git repository.

westonpace pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 463108d  ARROW-14667: [C++] Added a dcheck to ensure aws is 
initialized before s3 options are used
463108d is described below

commit 463108dda72aafd60fd37b960226585dcf777c4a
Author: Weston Pace <[email protected]>
AuthorDate: Thu Nov 18 22:08:21 2021 -1000

    ARROW-14667: [C++] Added a dcheck to ensure aws is initialized before s3 
options are used
    
    ARROW-14667 was fixed in R but we could probably do better to prevent this 
kind of thing.  Short of requiring `S3Options` to have a `Make` method we could 
just add a simple `DCHECK`.
    
    Closes #11697 from 
westonpace/bugfix/ARROW-14667--add-check-for-s3-init-to-options
    
    Authored-by: Weston Pace <[email protected]>
    Signed-off-by: Weston Pace <[email protected]>
---
 cpp/src/arrow/filesystem/s3fs.cc | 4 ++++
 cpp/src/arrow/filesystem/s3fs.h  | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/cpp/src/arrow/filesystem/s3fs.cc b/cpp/src/arrow/filesystem/s3fs.cc
index 49766d1..34fccd4 100644
--- a/cpp/src/arrow/filesystem/s3fs.cc
+++ b/cpp/src/arrow/filesystem/s3fs.cc
@@ -210,6 +210,10 @@ bool S3ProxyOptions::Equals(const S3ProxyOptions& other) 
const {
 // -----------------------------------------------------------------------
 // S3Options implementation
 
+S3Options::S3Options() {
+  DCHECK(aws_initialized.load()) << "Must initialize S3 before using 
S3Options";
+}
+
 void S3Options::ConfigureDefaultCredentials() {
   credentials_provider =
       std::make_shared<Aws::Auth::DefaultAWSCredentialsProviderChain>();
diff --git a/cpp/src/arrow/filesystem/s3fs.h b/cpp/src/arrow/filesystem/s3fs.h
index abb9c85..502353e 100644
--- a/cpp/src/arrow/filesystem/s3fs.h
+++ b/cpp/src/arrow/filesystem/s3fs.h
@@ -139,6 +139,8 @@ struct ARROW_EXPORT S3Options {
   /// delay between retries.
   std::shared_ptr<S3RetryStrategy> retry_strategy;
 
+  S3Options();
+
   /// Configure with the default AWS credentials provider chain.
   void ConfigureDefaultCredentials();
 

Reply via email to