From b256396b4872aaa3cacaa5973f8b243985324a37 Mon Sep 17 00:00:00 2001 From: Saikrishna Arcot Date: Thu, 26 Oct 2023 09:45:58 -0700 Subject: [PATCH] sonic-eventd: Use json.hpp from nlohmann-json3-dev instead of swss-common (#16818) #### Why I did it This header file comes from an external package, and a very old version of the header file has been checked into swss-common. This will cause problems for the upcoming Bookworm upgrade. ##### Work item tracking - Microsoft ADO **(number only)**: 25411155 #### How I did it Change references to the header file to use the Debian package nlohmann-json-dev, instead of from swss-common. ### Tested branch (Please provide the tested image version) - [ ] - [ ] VS image from pipeline build Verified that eventd was running --- src/sonic-eventd/rsyslog_plugin/rsyslog_plugin.cpp | 6 +++--- src/sonic-eventd/rsyslog_plugin/syslog_parser.h | 2 +- src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp | 2 +- src/sonic-eventd/tools/events_tool.cpp | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/sonic-eventd/rsyslog_plugin/rsyslog_plugin.cpp b/src/sonic-eventd/rsyslog_plugin/rsyslog_plugin.cpp index c660486f74..6df0a73b02 100644 --- a/src/sonic-eventd/rsyslog_plugin/rsyslog_plugin.cpp +++ b/src/sonic-eventd/rsyslog_plugin/rsyslog_plugin.cpp @@ -5,7 +5,7 @@ #include #include #include "rsyslog_plugin.h" -#include "json.hpp" +#include using json = nlohmann::json; @@ -56,7 +56,7 @@ bool RsyslogPlugin::createRegexList() { } try { regexFile >> jsonList; - } catch (invalid_argument& iaException) { + } catch (nlohmann::detail::parse_error& iaException) { SWSS_LOG_ERROR("Invalid JSON file: %s, throws exception: %s\n", m_regexPath.c_str(), iaException.what()); return false; } @@ -83,7 +83,7 @@ bool RsyslogPlugin::createRegexList() { rs.tag = tag; rs.regexExpression = expression; regexList.push_back(rs); - } catch (domain_error& deException) { + } catch (nlohmann::detail::type_error& deException) { SWSS_LOG_ERROR("Missing required key, throws exception: %s\n", deException.what()); return false; } catch (regex_error& reException) { diff --git a/src/sonic-eventd/rsyslog_plugin/syslog_parser.h b/src/sonic-eventd/rsyslog_plugin/syslog_parser.h index f912cf7e82..0d5217a35a 100644 --- a/src/sonic-eventd/rsyslog_plugin/syslog_parser.h +++ b/src/sonic-eventd/rsyslog_plugin/syslog_parser.h @@ -11,7 +11,7 @@ extern "C" #include #include #include -#include "json.hpp" +#include #include "events.h" #include "timestamp_formatter.h" diff --git a/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp b/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp index 4777f7376b..5ff41d11dd 100644 --- a/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp +++ b/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp @@ -9,7 +9,7 @@ extern "C" #include #include #include "gtest/gtest.h" -#include "json.hpp" +#include #include "events.h" #include "../rsyslog_plugin/rsyslog_plugin.h" #include "../rsyslog_plugin/syslog_parser.h" diff --git a/src/sonic-eventd/tools/events_tool.cpp b/src/sonic-eventd/tools/events_tool.cpp index d07f5887a8..8b969b2f80 100644 --- a/src/sonic-eventd/tools/events_tool.cpp +++ b/src/sonic-eventd/tools/events_tool.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "events.h" #include "events_common.h"