From dcac772061163870a17aca0b8b388703071bc3da Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Fri, 16 May 2025 17:51:18 +0000 Subject: [PATCH 1/2] Restore support for non-qualified message names Support for non-qualified message names in MessageFactory was removed in #476, but this is not yet supported in gz-transport. Restore the functionality for now to facilitate version bumps and then try removing it later. Signed-off-by: Steve Peters --- Migration.md | 5 ----- core/src/MessageFactory.cc | 13 +++++++++++++ test/integration/Factory_TEST.cc | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Migration.md b/Migration.md index 0eb49c26..a897b0d2 100644 --- a/Migration.md +++ b/Migration.md @@ -35,11 +35,6 @@ release will remove the deprecated code. const msgs::SphericalCoordinatesType &_sc)` does not accept `msgs::SphericalCoordinatesType::LOCAL2` anymore. -1. **MessageFactory.hh** - + The function `MessageFactory::MessagePtr MessageFactory::New( - const std::string &_msgType)` does not accept non-fully qualified names - anymore. - ## Gazebo Msgs 10.X to 11.X ### Deprecations diff --git a/core/src/MessageFactory.cc b/core/src/MessageFactory.cc index 09ab9252..d0b86117 100644 --- a/core/src/MessageFactory.cc +++ b/core/src/MessageFactory.cc @@ -94,6 +94,19 @@ MessageFactory::MessagePtr MessageFactory::New( }; auto ret = getMessagePtr(type); + + // Message was not found in either static or dynamic message types, + // try again adding the gz.msgs prefix + if (nullptr == ret) + { + ret = getMessagePtr(kGzMsgsPrefix + type); + if (nullptr != ret) + { + std::cerr << "Message (" << kGzMsgsPrefix + type + << ") was retrieved with non-fully qualified name. " + << "This behavior is deprecated in msgs12" << std::endl; + } + } return ret; } diff --git a/test/integration/Factory_TEST.cc b/test/integration/Factory_TEST.cc index fe15282c..37e7e2ca 100644 --- a/test/integration/Factory_TEST.cc +++ b/test/integration/Factory_TEST.cc @@ -100,7 +100,7 @@ TEST(FactoryTest, NewWithMalformedData) TEST(FactoryTest, DeprecatedNonFullyQualified) { auto msg = Factory::New("StringMsg"); - EXPECT_TRUE(msg.get() == nullptr); + EXPECT_TRUE(msg.get() != nullptr); } ///////////////////////////////////////////////// From 6be720222cc11ae63ec41854598f1edadb3337bf Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Fri, 16 May 2025 11:25:53 -0700 Subject: [PATCH 2/2] Update MessageFactory.cc Signed-off-by: Steve Peters --- core/src/MessageFactory.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/MessageFactory.cc b/core/src/MessageFactory.cc index d0b86117..fb365a90 100644 --- a/core/src/MessageFactory.cc +++ b/core/src/MessageFactory.cc @@ -102,6 +102,8 @@ MessageFactory::MessagePtr MessageFactory::New( ret = getMessagePtr(kGzMsgsPrefix + type); if (nullptr != ret) { + // Do not remove this until support is added to gz-transport: + // https://github.com/gazebosim/gz-transport/issues/435 std::cerr << "Message (" << kGzMsgsPrefix + type << ") was retrieved with non-fully qualified name. " << "This behavior is deprecated in msgs12" << std::endl;