From 9497e03709a035805effd96eaa21f6c221a79e94 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Fri, 19 Jan 2024 17:12:30 +0800
Subject: [PATCH 1/6] code improve for sandbox.cc

Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
 src/daemon/sandbox/sandbox.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/daemon/sandbox/sandbox.cc b/src/daemon/sandbox/sandbox.cc
index 359cfbad..7b6496ed 100644
--- a/src/daemon/sandbox/sandbox.cc
+++ b/src/daemon/sandbox/sandbox.cc
@@ -1086,8 +1086,7 @@ void Sandbox::FillSandboxMetadata(sandbox_metadata* metadata, Errors &error)
     metadata->task_address = util_strdup_s(m_taskAddress.c_str());
     metadata->net_ns_path = util_strdup_s(m_netNsPath.c_str());
 
-    google::protobuf::util::MessageToJsonString(*m_sandboxConfig.get(), &jsonStr);
-    if (jsonStr.length() == 0) {
+    if (!google::protobuf::util::MessageToJsonString(*m_sandboxConfig.get(), &jsonStr).ok()) {
         error.Errorf("Failed to get sandbox config json for sandbox: '%s'", m_id.c_str());
         ERROR("Failed to get sandbox config json for sandbox: '%s'", m_id.c_str());
     }
-- 
2.25.1

