diff -uar gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/detail/Node.hh gz-transport-gz-transport12_12.2.2.new/include/gz/transport/detail/Node.hh --- gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/detail/Node.hh 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/include/gz/transport/detail/Node.hh 2025-07-07 17:22:46.438115379 +0800 @@ -34,7 +34,7 @@ const std::string &_topic, const AdvertiseMessageOptions &_options) { - return this->Advertise(_topic, MessageT().GetTypeName(), _options); + return this->Advertise(_topic, std::string(MessageT().GetTypeName()), _options); } ////////////////////////////////////////////////// @@ -267,7 +267,7 @@ this->Shared()->myReplierAddress, this->Shared()->replierId.ToString(), this->Shared()->pUuid, this->NodeUuid(), - RequestT().GetTypeName(), ReplyT().GetTypeName(), _options); + std::string(RequestT().GetTypeName()), std::string(ReplyT().GetTypeName()), _options); if (!this->Shared()->AdvertisePublisher(publisher)) { @@ -420,8 +420,8 @@ std::lock_guard lk(this->Shared()->mutex); localResponserFound = this->Shared()->repliers.FirstHandler( fullyQualifiedTopic, - RequestT().GetTypeName(), - ReplyT().GetTypeName(), + std::string(RequestT().GetTypeName()), + std::string(ReplyT().GetTypeName()), repHandler); } @@ -458,7 +458,7 @@ if (this->Shared()->TopicPublishers(fullyQualifiedTopic, addresses)) { this->Shared()->SendPendingRemoteReqs(fullyQualifiedTopic, - RequestT().GetTypeName(), ReplyT().GetTypeName()); + std::string(RequestT().GetTypeName()), std::string(ReplyT().GetTypeName())); } else { @@ -551,7 +551,7 @@ // If the responser is within my process. IRepHandlerPtr repHandler; if (this->Shared()->repliers.FirstHandler(fullyQualifiedTopic, - _request.GetTypeName(), _reply.GetTypeName(), repHandler)) + std::string(_request.GetTypeName()), std::string(_reply.GetTypeName()), repHandler)) { // There is a responser in my process, let's use it. _result = repHandler->RunLocalCallback(_request, _reply); @@ -567,7 +567,7 @@ if (this->Shared()->TopicPublishers(fullyQualifiedTopic, addresses)) { this->Shared()->SendPendingRemoteReqs(fullyQualifiedTopic, - _request.GetTypeName(), _reply.GetTypeName()); + std::string(_request.GetTypeName()), std::string(_reply.GetTypeName())); } else { diff -uar gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/RepHandler.hh gz-transport-gz-transport12_12.2.2.new/include/gz/transport/RepHandler.hh --- gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/RepHandler.hh 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/include/gz/transport/RepHandler.hh 2025-07-07 17:19:25.149117798 +0800 @@ -142,9 +142,14 @@ } #if GOOGLE_PROTOBUF_VERSION >= 4022000 - auto msgReq = - google::protobuf::internal::DownCast(&_msgReq); - auto msgRep = google::protobuf::internal::DownCast(&_msgRep); + auto msgReq = dynamic_cast(&_msgReq); + auto msgRep = dynamic_cast(&_msgRep); + if (!msgReq || !msgRep) + { + std::cerr << "RepHandler::RunLocalCallback() error: " + << "dynamic_cast failed" << std::endl; + return false; + } #elif GOOGLE_PROTOBUF_VERSION > 2999999 auto msgReq = google::protobuf::down_cast(&_msgReq); auto msgRep = google::protobuf::down_cast(&_msgRep); @@ -193,13 +198,13 @@ // Documentation inherited. public: virtual std::string ReqTypeName() const { - return Req().GetTypeName(); + return std::string(Req().GetTypeName()); } // Documentation inherited. public: virtual std::string RepTypeName() const { - return Rep().GetTypeName(); + return std::string(Rep().GetTypeName()); } /// \brief Create a specific protobuf message given its serialized data. diff -uar gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/ReqHandler.hh gz-transport-gz-transport12_12.2.2.new/include/gz/transport/ReqHandler.hh --- gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/ReqHandler.hh 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/include/gz/transport/ReqHandler.hh 2025-07-07 17:14:56.341121030 +0800 @@ -285,13 +285,13 @@ // Documentation inherited. public: virtual std::string ReqTypeName() const { - return Req().GetTypeName(); + return std::string(Req().GetTypeName()); } // Documentation inherited. public: virtual std::string RepTypeName() const { - return Rep().GetTypeName(); + return std::string(Rep().GetTypeName()); } /// \brief Protobuf message containing the request's parameters. @@ -382,7 +382,7 @@ public: virtual std::string ReqTypeName() const { if (this->reqMsg) - return this->reqMsg->GetTypeName(); + return std::string(this->reqMsg->GetTypeName()); else { std::cerr << "ReqHandler::ReqTypeName() Warning: Using ReqTypeName() " @@ -395,7 +395,7 @@ public: virtual std::string RepTypeName() const { if (this->repMsg) - return this->repMsg->GetTypeName(); + return std::string(this->repMsg->GetTypeName()); else { std::cerr << "ReqHandler::RepTypeName() Warning: Using RepTypeName() " diff -uar gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/SubscriptionHandler.hh gz-transport-gz-transport12_12.2.2.new/include/gz/transport/SubscriptionHandler.hh --- gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/SubscriptionHandler.hh 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/include/gz/transport/SubscriptionHandler.hh 2025-07-07 17:13:08.673122324 +0800 @@ -184,7 +184,7 @@ // Documentation inherited. public: std::string TypeName() { - return T().GetTypeName(); + return std::string(T().GetTypeName()); } /// \brief Set the callback for this handler. @@ -211,7 +211,13 @@ return true; #if GOOGLE_PROTOBUF_VERSION >= 4022000 - auto msgPtr = google::protobuf::internal::DownCast(&_msg); + auto msgPtr = dynamic_cast(&_msg); + if (!msgPtr) + { + std::cerr << "SubscriptionHandler::RunLocalCallback() error: " + << "dynamic_cast failed" << std::endl; + return false; + } #elif GOOGLE_PROTOBUF_VERSION >= 3000000 auto msgPtr = google::protobuf::down_cast(&_msg); #else diff -uar gz-transport-gz-transport12_12.2.2.orig/parameters/src/Client.cc gz-transport-gz-transport12_12.2.2.new/parameters/src/Client.cc --- gz-transport-gz-transport12_12.2.2.orig/parameters/src/Client.cc 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/parameters/src/Client.cc 2025-07-07 17:27:01.814112309 +0800 @@ -216,7 +216,7 @@ return ParameterResult{ ParameterResultType::InvalidType, _parameterName, - _msg.GetDescriptor()->name()}; + std::string(_msg.GetDescriptor()->name())}; } return ParameterResult{ParameterResultType::Unexpected, _parameterName}; } diff -uar gz-transport-gz-transport12_12.2.2.orig/parameters/src/Registry.cc gz-transport-gz-transport12_12.2.2.new/parameters/src/Registry.cc --- gz-transport-gz-transport12_12.2.2.orig/parameters/src/Registry.cc 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/parameters/src/Registry.cc 2025-07-07 17:28:17.423111400 +0800 @@ -144,7 +144,7 @@ auto * decl = _res.add_parameter_declarations(); decl->set_name(paramPair.first); decl->set_type(addGzMsgsPrefix( - paramPair.second->GetDescriptor()->name())); + std::string(paramPair.second->GetDescriptor()->name()))); } } return true; @@ -238,7 +238,7 @@ const std::string & _parameterName, const google::protobuf::Message & _msg) { - auto protoType = addGzMsgsPrefix(_msg.GetDescriptor()->name()); + auto protoType = addGzMsgsPrefix(std::string(_msg.GetDescriptor()->name())); auto newParam = gz::msgs::Factory::New(protoType); if (!newParam) { return ParameterResult{ @@ -264,8 +264,8 @@ ParameterResultType::NotDeclared, _parameterName}; } - const auto & newProtoType = _parameter.GetDescriptor()->name(); - const auto & protoType = it->second->GetDescriptor()->name(); + const auto & newProtoType = std::string(_parameter.GetDescriptor()->name()); + const auto & protoType = std::string(it->second->GetDescriptor()->name()); if (newProtoType != protoType) { return ParameterResult{ ParameterResultType::InvalidType, @@ -289,7 +289,7 @@ ParameterResultType::NotDeclared, _parameterName}; } - const auto & protoType = it->second->GetDescriptor()->name(); + const auto & protoType = std::string(it->second->GetDescriptor()->name()); _parameter = gz::msgs::Factory::New(protoType); if (!_parameter) { return ParameterResult{ @@ -320,7 +320,7 @@ return ParameterResult{ ParameterResultType::InvalidType, _parameterName, - addGzMsgsPrefix(it->second->GetDescriptor()->name())}; + addGzMsgsPrefix(std::string(it->second->GetDescriptor()->name()))}; } it->second = std::move(_value); return ParameterResult{ParameterResultType::Success}; diff -uar gz-transport-gz-transport12_12.2.2.orig/src/CIface_TEST.cc gz-transport-gz-transport12_12.2.2.new/src/CIface_TEST.cc --- gz-transport-gz-transport12_12.2.2.orig/src/CIface_TEST.cc 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/src/CIface_TEST.cc 2025-07-07 17:17:13.756119378 +0800 @@ -96,7 +96,7 @@ msg.SerializeToArray(buffer, size); EXPECT_EQ(0, - gzTransportPublish(node, topic, buffer, msg.GetTypeName().c_str())); + gzTransportPublish(node, topic, buffer, std::string(msg.GetTypeName()).c_str())); EXPECT_EQ(2, count); @@ -105,7 +105,7 @@ // Unsubscribe ASSERT_EQ(0, gzTransportUnsubscribe(node, topic)); EXPECT_EQ(0, - gzTransportPublish(node, topic, buffer, msg.GetTypeName().c_str())); + gzTransportPublish(node, topic, buffer, std::string(msg.GetTypeName()).c_str())); EXPECT_EQ(0, count); free(buffer); @@ -153,12 +153,12 @@ // Publish on "bar" partition EXPECT_EQ(0, - gzTransportPublish(nodeBar, topic, buffer, msg.GetTypeName().c_str())); + gzTransportPublish(nodeBar, topic, buffer, std::string(msg.GetTypeName()).c_str())); EXPECT_EQ(1, count); // Publish on default partition EXPECT_EQ(0, - gzTransportPublish(nodeBar, topic, buffer, msg.GetTypeName().c_str())); + gzTransportPublish(nodeBar, topic, buffer, std::string(msg.GetTypeName()).c_str())); EXPECT_EQ(2, count); count = 0; @@ -166,7 +166,7 @@ // Unsubscribe ASSERT_EQ(0, gzTransportUnsubscribe(nodeBar, topic)); EXPECT_EQ(0, - gzTransportPublish(nodeBar, topic, buffer, msg.GetTypeName().c_str())); + gzTransportPublish(nodeBar, topic, buffer, std::string(msg.GetTypeName()).c_str())); EXPECT_EQ(0, count); free(buffer); diff -uar gz-transport-gz-transport12_12.2.2.orig/src/cmd/gz.cc gz-transport-gz-transport12_12.2.2.new/src/cmd/gz.cc --- gz-transport-gz-transport12_12.2.2.orig/src/cmd/gz.cc 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/src/cmd/gz.cc 2025-07-07 17:23:28.582114872 +0800 @@ -162,7 +162,7 @@ { // Create the node and advertise the topic Node node; - auto pub = node.Advertise(_topic, msg->GetTypeName()); + auto pub = node.Advertise(_topic, std::string(msg->GetTypeName())); // Publish the message if (pub) diff -uar gz-transport-gz-transport12_12.2.2.orig/src/HandlerStorage_TEST.cc gz-transport-gz-transport12_12.2.2.new/src/HandlerStorage_TEST.cc --- gz-transport-gz-transport12_12.2.2.orig/src/HandlerStorage_TEST.cc 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/src/HandlerStorage_TEST.cc 2025-07-07 17:17:46.532118984 +0800 @@ -67,8 +67,8 @@ msgs::Int32 rep1Msg; bool result; msgs::Vector3d reqMsg; - std::string reqType = reqMsg.GetTypeName(); - std::string rep1Type = rep1Msg.GetTypeName(); + std::string reqType = std::string(reqMsg.GetTypeName()); + std::string rep1Type = std::string(rep1Msg.GetTypeName()); reqMsg.set_x(1.0); reqMsg.set_y(2.0); @@ -232,7 +232,7 @@ EXPECT_FALSE(subs.FirstHandler(topic, "incorrect type", handler)); // Now try to retrieve the first callback with the correct type. - EXPECT_TRUE(subs.FirstHandler(topic, msg.GetTypeName(), handler)); + EXPECT_TRUE(subs.FirstHandler(topic, std::string(msg.GetTypeName()), handler)); // Verify the handler. EXPECT_EQ(handler->TypeName(), sub1HandlerPtr->TypeName()); diff -uar gz-transport-gz-transport12_12.2.2.orig/src/Node.cc gz-transport-gz-transport12_12.2.2.new/src/Node.cc --- gz-transport-gz-transport12_12.2.2.orig/src/Node.cc 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/src/Node.cc 2025-07-07 17:14:16.412121510 +0800 @@ -418,7 +418,7 @@ }; if (!this->dataPtr->shared->Publish(this->dataPtr->publisher.Topic(), - msgBuffer, msgSize, myDeallocator, _msg.GetTypeName())) + msgBuffer, msgSize, myDeallocator, std::string(_msg.GetTypeName()))) { return false; } diff -uar gz-transport-gz-transport12_12.2.2.orig/src/Node_TEST.cc gz-transport-gz-transport12_12.2.2.new/src/Node_TEST.cc --- gz-transport-gz-transport12_12.2.2.orig/src/Node_TEST.cc 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/src/Node_TEST.cc 2025-07-07 17:20:54.837116720 +0800 @@ -346,8 +346,8 @@ // Request a valid service using RequestRaw. std::string reqStr, repStr, repTypeName; req.SerializeToString(&reqStr); - EXPECT_TRUE(this->node.RequestRaw(g_topic, reqStr, req.GetTypeName(), - rep.GetTypeName(), timeout, repStr, result)); + EXPECT_TRUE(this->node.RequestRaw(g_topic, reqStr, std::string(req.GetTypeName()), + std::string(rep.GetTypeName()), timeout, repStr, result)); rep.ParseFromString(repStr); ASSERT_TRUE(result); EXPECT_EQ(rep.data(), data); @@ -541,7 +541,7 @@ EXPECT_TRUE(node1.SubscribedTopics().empty()); EXPECT_TRUE(node1.AdvertisedServices().empty()); - auto pub1 = node1.Advertise(g_topic, msg.GetTypeName()); + auto pub1 = node1.Advertise(g_topic, std::string(msg.GetTypeName())); EXPECT_TRUE(pub1); auto advertisedTopics = node1.AdvertisedTopics(); @@ -730,7 +730,7 @@ std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Publish a first message. - EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), msg.GetTypeName())); + EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), std::string(msg.GetTypeName()))); // Give some time to the subscribers. std::this_thread::sleep_for(std::chrono::milliseconds(100)); @@ -741,7 +741,7 @@ reset(); // Publish a second message on topic. - EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), msg.GetTypeName())); + EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), std::string(msg.GetTypeName()))); // Give some time to the subscribers. std::this_thread::sleep_for(std::chrono::milliseconds(100)); @@ -770,7 +770,7 @@ std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Publish a first message. - EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), msg.GetTypeName())); + EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), std::string(msg.GetTypeName()))); // Give some time to the subscribers. std::this_thread::sleep_for(std::chrono::milliseconds(100)); @@ -781,7 +781,7 @@ reset(); // Publish a second message on topic. - EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), msg.GetTypeName())); + EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), std::string(msg.GetTypeName()))); // Give some time to the subscribers. std::this_thread::sleep_for(std::chrono::milliseconds(100)); diff -uar gz-transport-gz-transport12_12.2.2.orig/test/integration/test_executables/twoProcsPubSubSubscriber_aux.cc gz-transport-gz-transport12_12.2.2.new/test/integration/test_executables/twoProcsPubSubSubscriber_aux.cc --- gz-transport-gz-transport12_12.2.2.orig/test/integration/test_executables/twoProcsPubSubSubscriber_aux.cc 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/test/integration/test_executables/twoProcsPubSubSubscriber_aux.cc 2025-07-07 17:26:12.086112907 +0800 @@ -100,7 +100,7 @@ // Add a raw subscription to `node` EXPECT_TRUE(node.SubscribeRaw(g_topic, cbRaw, - msgs::Vector3d().GetTypeName())); + std::string(msgs::Vector3d().GetTypeName()))); int interval = 100; diff -uar gz-transport-gz-transport12_12.2.2.orig/test/integration/twoProcsPubSub.cc gz-transport-gz-transport12_12.2.2.new/test/integration/twoProcsPubSub.cc --- gz-transport-gz-transport12_12.2.2.orig/test/integration/twoProcsPubSub.cc 2024-11-08 04:08:54.000000000 +0800 +++ gz-transport-gz-transport12_12.2.2.new/test/integration/twoProcsPubSub.cc 2025-07-07 17:24:30.918114123 +0800 @@ -166,7 +166,7 @@ // Publish messages for a few seconds for (auto i = 0; i < 10; ++i) { - EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), msg.GetTypeName())); + EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), std::string(msg.GetTypeName()))); std::this_thread::sleep_for(std::chrono::milliseconds(500)); } } @@ -204,7 +204,7 @@ transport::Node node; EXPECT_TRUE(node.SubscribeRaw(g_topic, cbRaw, - msgs::Int32().GetTypeName())); + std::string(msgs::Int32().GetTypeName()))); // Wait some time before publishing. std::this_thread::sleep_for(std::chrono::milliseconds(1500)); @@ -290,7 +290,7 @@ transport::Node node3; EXPECT_TRUE(node1.SubscribeRaw(g_topic, wrongCb, "wrong.msg.type")); EXPECT_TRUE(node2.SubscribeRaw(g_topic, correctCb, - msgs::Vector3d().GetTypeName())); + std::string(msgs::Vector3d().GetTypeName()))); EXPECT_TRUE(node3.SubscribeRaw(g_topic, genericCb));