diff --git a/mgmt/rpc/jsonrpc/JsonRPCManager.cc b/mgmt/rpc/jsonrpc/JsonRPCManager.cc index fc3ce0b13da..589e694976e 100644 --- a/mgmt/rpc/jsonrpc/JsonRPCManager.cc +++ b/mgmt/rpc/jsonrpc/JsonRPCManager.cc @@ -130,16 +130,14 @@ JsonRPCManager::Dispatcher::find_handler(specs::RPCRequestInfo const &request, s std::lock_guard lock(_mutex); - auto search = _handlers.find(request.method); + InternalHandlers::const_iterator search = _handlers.find(request.method); if (search == std::end(_handlers)) { // no more checks, no handler either notification or method ec = error::RPCErrorCode::METHOD_NOT_FOUND; return no_handler; - } - - // Handler's method type should match the requested method type. - if ((request.is_method() && search->second.is_method()) || (request.is_notification() && !search->second.is_method())) { + } // Handler's method type should match the requested method type. + else if ((request.is_method() && search->second.is_method()) || (request.is_notification() && !search->second.is_method())) { return search->second; } diff --git a/mgmt/rpc/jsonrpc/JsonRPCManager.h b/mgmt/rpc/jsonrpc/JsonRPCManager.h index 24777fc6b7a..c69ef619dd7 100644 --- a/mgmt/rpc/jsonrpc/JsonRPCManager.h +++ b/mgmt/rpc/jsonrpc/JsonRPCManager.h @@ -194,6 +194,8 @@ class JsonRPCManager }; struct InternalHandler; ///< fw declaration + /// To avoid long lines. + using InternalHandlers = std::unordered_map; public: Dispatcher(); @@ -276,8 +278,8 @@ class JsonRPCManager }; // We will keep all the handlers wrapped inside the InternalHandler class, this will help us // to have a single container for all the types(method, notification & plugin method(cond var)). - std::unordered_map _handlers; ///< Registered handler container. - mutable std::mutex _mutex; ///< insert/find/delete mutex. + InternalHandlers _handlers; ///< Registered handler container. + mutable std::mutex _mutex; ///< insert/find/delete mutex. }; Dispatcher _dispatcher; ///< Internal handler container and dispatcher logic object.