From 6b4409ddaea325b81dadbc589c697d235ed82703 Mon Sep 17 00:00:00 2001 From: Santti4go Date: Mon, 30 Dec 2024 14:03:12 -0300 Subject: [PATCH 1/3] Log any errors before cancel_init() Signed-off-by: Santti4go --- src/cpp/rtps/security/SecurityManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index 9852e875743..6fe89562841 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -117,9 +117,9 @@ bool SecurityManager::init( ParticipantSecurityAttributes& attributes, const PropertyPolicy& participant_properties) { + SecurityException exception; try { - SecurityException exception; domain_id_ = participant_->get_domain_id(); auto part_attributes = participant_->get_attributes(); const PropertyPolicy log_properties = PropertyPolicyHelper::get_properties_with_prefix( @@ -396,6 +396,10 @@ bool SecurityManager::init( { if (!e) { + // Unexpected code path. Let's log any errors + logError(SECURITY, "Error while configuring security plugin.") + if (strlen(exception.what())) logError(SECURITY, exception.what()) + cancel_init(); return false; } From c6c380c5a2c979510317df548acf978c744f3796 Mon Sep 17 00:00:00 2001 From: Santti4go Date: Mon, 30 Dec 2024 18:22:27 -0300 Subject: [PATCH 2/3] Code style Signed-off-by: Santti4go --- src/cpp/rtps/security/SecurityManager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index 6fe89562841..640f9e0d3db 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -398,7 +398,10 @@ bool SecurityManager::init( { // Unexpected code path. Let's log any errors logError(SECURITY, "Error while configuring security plugin.") - if (strlen(exception.what())) logError(SECURITY, exception.what()) + if (strlen(exception.what())) + { + logError(SECURITY, exception.what()) + } cancel_init(); return false; From 5cc9d57cd9f9bed0c3b20b90202a5d2b17edec8d Mon Sep 17 00:00:00 2001 From: Santti4go Date: Fri, 3 Jan 2025 12:13:56 -0300 Subject: [PATCH 3/3] Apply suggestion Signed-off-by: Santti4go --- src/cpp/rtps/security/SecurityManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index 640f9e0d3db..aa66847770d 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -398,7 +398,7 @@ bool SecurityManager::init( { // Unexpected code path. Let's log any errors logError(SECURITY, "Error while configuring security plugin.") - if (strlen(exception.what())) + if (0 != strlen(exception.what())) { logError(SECURITY, exception.what()) }