From 35523a5a77687793d413b9b68563bd9061d35891 Mon Sep 17 00:00:00 2001 From: Janosch Machowinski Date: Tue, 25 Jun 2024 10:55:24 +0200 Subject: [PATCH] fix: added workaround for call to double calls to take_data This adds a workaround for a known bug in the executor in iron. Signed-off-by: Janosch Machowinski --- rclcpp_action/src/server.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rclcpp_action/src/server.cpp b/rclcpp_action/src/server.cpp index 8b94cf1488..1f615fb89b 100644 --- a/rclcpp_action/src/server.cpp +++ b/rclcpp_action/src/server.cpp @@ -273,8 +273,10 @@ ServerBase::take_data() { size_t next_ready_event = pimpl_->next_ready_event.exchange(ServerBaseImpl::NO_EVENT_READY); - if (next_ready_event == ServerBaseImpl::NO_EVENT_READY;) { - throw std::runtime_error("ServerBase::take_data() called but no data is ready"); + if (next_ready_event == ServerBaseImpl::NO_EVENT_READY) { + // there is a known bug in iron, that take_data might be called multiple + // times. Therefore instead of throwing, we just return a nullptr as a workaround. + return nullptr; } return take_data_by_entity_id(next_ready_event); @@ -363,7 +365,9 @@ void ServerBase::execute(std::shared_ptr & data_in) { if (!data_in) { - throw std::runtime_error("ServerBase::execute: give data pointer was null"); + // workaround, if take_data was called multiple timed, it returns a nullptr + // normally we should throw here, but as an API stable bug fix, we just ignore this... + return; } std::shared_ptr data_ptr = std::static_pointer_cast(data_in);