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

martinzink pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new e796c7f97 MINIFICPP-2451 Upgrade aws-sdk-cpp from 1.11.219 to 1.11.396
e796c7f97 is described below

commit e796c7f97c5820cdb3f1783a5a3f29b4620ec3a0
Author: Ferenc Gerlits <[email protected]>
AuthorDate: Fri Sep 6 09:34:57 2024 +0200

    MINIFICPP-2451 Upgrade aws-sdk-cpp from 1.11.219 to 1.11.396
    
    Closes #1862
    
    Signed-off-by: Martin Zink <[email protected]>
---
 cmake/BundledAwsSdkCpp.cmake                      |  2 +-
 extensions/aws/tests/AWSSdkLoggerTests.cpp        | 64 +++++++++++++++++++++++
 extensions/aws/utils/AWSSdkLogger.cpp             | 34 ++++++++++--
 extensions/aws/utils/AWSSdkLogger.h               | 16 ++----
 thirdparty/aws-sdk-cpp/bundle-openssl.patch       | 26 ++-------
 thirdparty/aws-sdk-cpp/dll-export-injection.patch |  2 +-
 thirdparty/aws-sdk-cpp/shutdown-fix.patch         |  2 +-
 7 files changed, 105 insertions(+), 41 deletions(-)

diff --git a/cmake/BundledAwsSdkCpp.cmake b/cmake/BundledAwsSdkCpp.cmake
index 74c90bf6a..222a89940 100644
--- a/cmake/BundledAwsSdkCpp.cmake
+++ b/cmake/BundledAwsSdkCpp.cmake
@@ -81,7 +81,7 @@ function(use_bundled_libaws SOURCE_DIR BINARY_DIR)
     ExternalProject_Add(
             aws-sdk-cpp-external
             GIT_REPOSITORY "https://github.com/aws/aws-sdk-cpp.git";
-            GIT_TAG "1.11.219"
+            GIT_TAG "1.11.396"
             UPDATE_COMMAND git submodule update --init --recursive
             SOURCE_DIR "${BINARY_DIR}/thirdparty/aws-sdk-cpp-src"
             INSTALL_DIR "${BINARY_DIR}/thirdparty/libaws-install"
diff --git a/extensions/aws/tests/AWSSdkLoggerTests.cpp 
b/extensions/aws/tests/AWSSdkLoggerTests.cpp
new file mode 100644
index 000000000..18393d60b
--- /dev/null
+++ b/extensions/aws/tests/AWSSdkLoggerTests.cpp
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "aws/core/utils/logging/LogLevel.h"
+#include "aws/core/utils/memory/stl/AWSStringStream.h"
+#include "fmt/format.h"
+#include "unit/Catch.h"
+#include "unit/TestBase.h"
+#include "utils/AWSSdkLogger.h"
+
+using AWSSdkLogger = minifi::aws::utils::AWSSdkLogger;
+using AwsLogLevel = Aws::Utils::Logging::LogLevel;
+
+TEST_CASE("We can log to the MiNiFi log via the AWS SDK logger") {
+  AWSSdkLogger sdk_logger;
+  LogTestController::getInstance().setInfo<AWSSdkLogger>();
+  LogTestController::getInstance().clear();
+
+  SECTION("using the Log() function") {
+    static constexpr const char* format_string = "On the %s day of Christmas 
my true love gave to me %d %s";
+    sdk_logger.Log(AwsLogLevel::Debug, "test", format_string, "first", 1, 
"partridge in a pear tree");
+    sdk_logger.Log(AwsLogLevel::Info, "test", format_string, "second", 2, 
"turtle doves");
+    sdk_logger.Log(AwsLogLevel::Error, "test", format_string, "third", 4, 
"German shepherds");
+  }
+
+  SECTION("using the vaLog() function") {
+    const auto vaLogger = [&sdk_logger](AwsLogLevel log_level, const char* 
tag, const char* format_string, ...) {  // NOLINT(cert-dcl50-cpp)
+      va_list args;
+      va_start(args, format_string);
+      sdk_logger.vaLog(log_level, tag, format_string, args);
+      va_end(args);
+    };
+
+    static constexpr const char* format_string = "On the %s day of Christmas 
my true love gave to me %d %s";
+    vaLogger(AwsLogLevel::Debug, "test", format_string, "first", 1, "partridge 
in a pear tree");
+    vaLogger(AwsLogLevel::Info, "test", format_string, "second", 2, "turtle 
doves");
+    vaLogger(AwsLogLevel::Error, "test", format_string, "third", 4, "German 
shepherds");
+  }
+
+  SECTION("using the LogStream() function") {
+    static constexpr std::string_view format_string = "On the {} day of 
Christmas my true love gave to me {} {}";
+    sdk_logger.LogStream(AwsLogLevel::Debug, "test", 
Aws::OStringStream{fmt::format(format_string, "first", 1, "partridge in a pear 
tree")});
+    sdk_logger.LogStream(AwsLogLevel::Info, "test", 
Aws::OStringStream{fmt::format(format_string, "second", 2, "turtle doves")});
+    sdk_logger.LogStream(AwsLogLevel::Error, "test", 
Aws::OStringStream{fmt::format(format_string, "third", 4, "German shepherds")});
+  }
+
+  CHECK_FALSE(LogTestController::getInstance().contains("partridge in a pear 
tree"));
+  
CHECK(LogTestController::getInstance().contains("[org::apache::nifi::minifi::aws::utils::AWSSdkLogger]
 [info] [test] On the second day of Christmas my true love gave to me 2 turtle 
doves"));
+  
CHECK(LogTestController::getInstance().contains("[org::apache::nifi::minifi::aws::utils::AWSSdkLogger]
 [error] [test] On the third day of Christmas my true love gave to me 4 German 
shepherds"));
+}
diff --git a/extensions/aws/utils/AWSSdkLogger.cpp 
b/extensions/aws/utils/AWSSdkLogger.cpp
index 0738bbd25..28ad55e93 100644
--- a/extensions/aws/utils/AWSSdkLogger.cpp
+++ b/extensions/aws/utils/AWSSdkLogger.cpp
@@ -19,7 +19,10 @@
  */
 #include "AWSSdkLogger.h"
 
+#include <cstdio>
+
 #include "aws/core/utils/logging/LogLevel.h"
+#include "utils/gsl.h"
 
 namespace org::apache::nifi::minifi::aws::utils {
 
@@ -60,11 +63,36 @@ Aws::Utils::Logging::LogLevel AWSSdkLogger::GetLogLevel() 
const {
 }
 
 void AWSSdkLogger::Log(Aws::Utils::Logging::LogLevel log_level, const char* 
tag, const char* format_str, ...) {  // NOLINT(cert-dcl50-cpp)
-  logger_->log_with_level(mapFromAwsLevels(log_level), "[{}] {}", tag, 
format_str);
+  va_list args;
+  va_start(args, format_str);
+  vaLog(log_level, tag, format_str, args);
+  va_end(args);
+}
+
+void AWSSdkLogger::vaLog(Aws::Utils::Logging::LogLevel log_level, const char* 
tag, const char* format_str, va_list args) {
+  va_list args_copy;
+  va_copy(args_copy, args);
+  const int buffer_size = std::vsnprintf(nullptr, 0, format_str, args_copy) + 
1;  // +1 for the terminating \0 character
+  va_end(args_copy);
+
+  std::vector<char> buffer(buffer_size);
+
+  const int length = std::vsnprintf(buffer.data(), buffer_size, format_str, 
args);
+  if (length < 0) {
+    logger_->log_error("A log line from aws-sdk-cpp could not be processed: 
[{}] {}", tag, format_str);
+    return;
+  }
+  gsl_Assert(length <= buffer_size);
+
+  log(log_level, tag, std::string_view(buffer.data(), length));
+}
+
+void AWSSdkLogger::LogStream(Aws::Utils::Logging::LogLevel log_level, const 
char* tag, const Aws::OStringStream& message_stream) {
+  log(log_level, tag, message_stream.str());
 }
 
-void AWSSdkLogger::LogStream(Aws::Utils::Logging::LogLevel log_level, const 
char* tag, const Aws::OStringStream &message_stream) {
-  Log(log_level, tag, message_stream.str().c_str());
+void AWSSdkLogger::log(Aws::Utils::Logging::LogLevel log_level, const char* 
tag, std::string_view message) const {
+  logger_->log_with_level(mapFromAwsLevels(log_level), "[{}] {}", tag, 
message);
 }
 
 void AWSSdkLogger::Flush() {
diff --git a/extensions/aws/utils/AWSSdkLogger.h 
b/extensions/aws/utils/AWSSdkLogger.h
index 87f764a71..04bb77c42 100644
--- a/extensions/aws/utils/AWSSdkLogger.h
+++ b/extensions/aws/utils/AWSSdkLogger.h
@@ -25,27 +25,19 @@
 #include "core/logging/Logger.h"
 #include "core/logging/LoggerConfiguration.h"
 
-namespace org {
-namespace apache {
-namespace nifi {
-namespace minifi {
-namespace aws {
-namespace utils {
+namespace org::apache::nifi::minifi::aws::utils {
 
 class AWSSdkLogger : public Aws::Utils::Logging::LogSystemInterface {
  public:
   [[nodiscard]] Aws::Utils::Logging::LogLevel GetLogLevel() const override;
   void Log(Aws::Utils::Logging::LogLevel log_level, const char* tag, const 
char* format_str, ...) override;
+  void vaLog(Aws::Utils::Logging::LogLevel log_level, const char* tag, const 
char* format_str, va_list args) override;
   void LogStream(Aws::Utils::Logging::LogLevel log_level, const char* tag, 
const Aws::OStringStream &message_stream) override;
   void Flush() override;
 
  private:
+  void log(Aws::Utils::Logging::LogLevel log_level, const char* tag, 
std::string_view message) const;
   std::shared_ptr<core::logging::Logger> 
logger_{core::logging::LoggerFactory<AWSSdkLogger>::getLogger()};
 };
 
-} /* namespace utils */
-} /* namespace aws */
-} /* namespace minifi */
-} /* namespace nifi */
-} /* namespace apache */
-} /* namespace org */
+}  // namespace org::apache::nifi::minifi::aws::utils
diff --git a/thirdparty/aws-sdk-cpp/bundle-openssl.patch 
b/thirdparty/aws-sdk-cpp/bundle-openssl.patch
index 118667c07..aa419d620 100644
--- a/thirdparty/aws-sdk-cpp/bundle-openssl.patch
+++ b/thirdparty/aws-sdk-cpp/bundle-openssl.patch
@@ -1,27 +1,7 @@
-diff -rupN a/cmake/external_dependencies.cmake 
b/cmake/external_dependencies.cmake
---- a/cmake/external_dependencies.cmake 2023-12-11 13:15:43.194940468 +0100
-+++ b/cmake/external_dependencies.cmake 2023-12-11 13:30:56.553108740 +0100
-@@ -40,14 +40,14 @@ elseif(ENABLE_OPENSSL_ENCRYPTION)
-     add_definitions(-DENABLE_OPENSSL_ENCRYPTION)
-     message(STATUS "Encryption: LibCrypto")
-
--    set(CRYPTO_TARGET_NAME "AWS::crypto")
-+    set(CRYPTO_TARGET_NAME "OpenSSL::Crypto")
-     if(PLATFORM_ANDROID AND ANDROID_BUILD_OPENSSL)
-         set(BUILD_OPENSSL 1)
-         set(CRYPTO_TARGET_NAME "crypto")
-         set(USE_OPENSSL ON)
-         message(STATUS "  Building Openssl as part of AWS SDK")
-     else()
--        find_package(crypto REQUIRED)
-+        find_package(OpenSSL REQUIRED)
-     endif()
-     set(CRYPTO_LIBS ${CRYPTO_TARGET_NAME} ${ZLIB_LIBRARIES})
-     # ssl depends on libcrypto
 diff -rupN a/crt/aws-crt-cpp/crt/s2n/CMakeLists.txt 
b/crt/aws-crt-cpp/crt/s2n/CMakeLists.txt
 --- a/crt/aws-crt-cpp/crt/s2n/CMakeLists.txt    2023-12-11 13:15:44.264958227 
+0100
 +++ b/crt/aws-crt-cpp/crt/s2n/CMakeLists.txt    2023-12-11 13:34:38.190054072 
+0100
-@@ -262,9 +262,9 @@ if (TARGET crypto)
+@@ -240,9 +240,9 @@ if (TARGET crypto)
      message(STATUS "S2N found target: crypto")
      set(LINK_LIB "crypto")
  else()
@@ -33,7 +13,7 @@ diff -rupN a/crt/aws-crt-cpp/crt/s2n/CMakeLists.txt 
b/crt/aws-crt-cpp/crt/s2n/CM
  endif()
 
  if (S2N_INTERN_LIBCRYPTO)
-@@ -395,11 +395,11 @@ feature_probe_result(S2N_KYBER512R3_AVX2
+@@ -347,11 +347,11 @@ feature_probe_result(S2N_KYBER512R3_AVX2
 
  if (S2N_INTERN_LIBCRYPTO)
 
@@ -49,7 +29,7 @@ diff -rupN a/crt/aws-crt-cpp/crt/s2n/CMakeLists.txt 
b/crt/aws-crt-cpp/crt/s2n/CM
 
          # If we didn't find the a target with static library type, fallback to
          # existing crypto_STATIC_LIBRARY and crypto_INCLUDE_DIR
-@@ -408,8 +408,8 @@ if (S2N_INTERN_LIBCRYPTO)
+@@ -360,8 +360,8 @@ if (S2N_INTERN_LIBCRYPTO)
              # The finder module defines these appropriately, but if we go 
through
              # the target config we need to query this information from the 
target
              # first.
diff --git a/thirdparty/aws-sdk-cpp/dll-export-injection.patch 
b/thirdparty/aws-sdk-cpp/dll-export-injection.patch
index 4e275db74..1343f00c7 100644
--- a/thirdparty/aws-sdk-cpp/dll-export-injection.patch
+++ b/thirdparty/aws-sdk-cpp/dll-export-injection.patch
@@ -36,7 +36,7 @@ diff -rupN 
a/generated/src/aws-cpp-sdk-s3/include/aws/s3/S3_EXPORTS.h b/generate
 diff -rupN a/src/aws-cpp-sdk-core/CMakeLists.txt 
b/src/aws-cpp-sdk-core/CMakeLists.txt
 --- a/src/aws-cpp-sdk-core/CMakeLists.txt      2023-12-11 13:15:52.061754319 
+0100
 +++ b/src/aws-cpp-sdk-core/CMakeLists.txt      2023-12-14 14:01:42.666518935 
+0100
-@@ -608,6 +608,11 @@ elseif (BUILD_SHARED_LIBS)
+@@ -682,6 +682,11 @@ elseif (BUILD_SHARED_LIBS)
      target_compile_definitions(${PROJECT_NAME} PRIVATE "SMITHY_EXPORTS=1")
  endif()
  
diff --git a/thirdparty/aws-sdk-cpp/shutdown-fix.patch 
b/thirdparty/aws-sdk-cpp/shutdown-fix.patch
index 90ccc400c..92a5c7e2d 100644
--- a/thirdparty/aws-sdk-cpp/shutdown-fix.patch
+++ b/thirdparty/aws-sdk-cpp/shutdown-fix.patch
@@ -2,7 +2,7 @@ diff --git a/crt/aws-crt-cpp/crt/aws-c-io/source/event_loop.c 
b/crt/aws-crt-cpp/
 index c37aaf6..2a45c21 100644
 --- a/crt/aws-crt-cpp/crt/aws-c-io/source/event_loop.c
 +++ b/crt/aws-crt-cpp/crt/aws-c-io/source/event_loop.c
-@@ -114,7 +114,7 @@ static struct aws_event_loop_group *s_event_loop_group_new(
+@@ -110,7 +110,7 @@ static struct aws_event_loop_group *s_event_loop_group_new(
  
      el_group->allocator = alloc;
      aws_ref_count_init(

Reply via email to