Skip to content

Commit 47fd21c

Browse files
Mauro PasserinoAlberto Soragna
authored andcommitted
Don't throw on empty intra-process buffer
1 parent 4827ceb commit 47fd21c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

rclcpp/include/rclcpp/experimental/buffers/ring_buffer_implementation.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class RingBufferImplementation : public BufferImplementationBase<BufferT>
7575

7676
if (!has_data()) {
7777
RCLCPP_ERROR(rclcpp::get_logger("rclcpp"), "Calling dequeue on empty intra-process buffer");
78-
throw std::runtime_error("Calling dequeue on empty intra-process buffer");
78+
return BufferT();
7979
}
8080

8181
auto request = std::move(ring_buffer_[read_index_]);

rclcpp/include/rclcpp/experimental/subscription_intra_process.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ class SubscriptionIntraProcess : public SubscriptionIntraProcessBase
159159

160160
if (any_callback_.use_take_shared_method()) {
161161
ConstMessageSharedPtr msg = buffer_->consume_shared();
162-
any_callback_.dispatch_intra_process(msg, msg_info);
162+
if(msg != nullptr) {
163+
any_callback_.dispatch_intra_process(msg, msg_info);
164+
}
163165
} else {
164166
MessageUniquePtr msg = buffer_->consume_unique();
165167
any_callback_.dispatch_intra_process(std::move(msg), msg_info);

0 commit comments

Comments
 (0)