Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

WHISTLE-788: ensure category, key, and node are binary before process…

…ing config requests
  • Loading branch information...
commit ce78a869f20410e5a7f1ce9999ea874b9f9690c0 1 parent c752ae1
@jamesaimonetti jamesaimonetti authored
Showing with 12 additions and 9 deletions.
  1. +12 −9 whistle_apps/src/whapps_config.erl
View
21 whistle_apps/src/whapps_config.erl
@@ -194,15 +194,14 @@ get_non_empty(Category, Key, Default, Node) ->
-spec get/4 :: (config_category(), config_key(), Default, ne_binary()) -> term() | Default.
get(Category, Key) ->
get(Category, Key, undefined).
-
-get(Category, Key, Default) when not is_binary(Category)->
- get(wh_util:to_binary(Category), Key, Default);
-get(Category, Key, Default) when not is_binary(Key)->
- get(Category, wh_util:to_binary(Key), Default);
get(Category, Key, Default) ->
- get(Category, Key, Default, wh_util:to_binary(node())).
+ get(Category, Key, Default, node()).
+
+get(Category0, Key0, Default, Node0) ->
+ Category = wh_util:to_binary(Category0),
+ Key = wh_util:to_binary(Key0),
+ Node = wh_util:to_binary(Node0),
-get(Category, Key, Default, Node) ->
{ok, Cache} = whistle_apps_sup:config_cache_proc(),
case fetch_category(Category, Cache) of
{ok, JObj} ->
@@ -267,7 +266,7 @@ get_all_kvs(Category) ->
-spec set/3 :: (config_category(), config_key(), term()) -> {'ok', wh_json:json_object()}.
-spec set/4 :: (config_category(), config_key(), term(), ne_binary()) -> {'ok', wh_json:json_object()}.
set(Category, Key, Value) ->
- set(Category, Key, Value, wh_util:to_binary(node())).
+ set(Category, Key, Value, node()).
set(Category, Key, Value, Node) ->
do_set(Category, Key, Value, Node).
@@ -391,7 +390,11 @@ config_terms_to_json(Terms) ->
%% @end
%%-----------------------------------------------------------------------------
-spec do_set/4 :: (config_category(), config_key(), term(), ne_binary()) -> {'ok', wh_json:json_object()}.
-do_set(Category, Key, Value, Node) ->
+do_set(Category0, Key0, Value, Node0) ->
+ Category = wh_util:to_binary(Category0),
+ Key = wh_util:to_binary(Key0),
+ Node = wh_util:to_binary(Node0),
+
{ok, Cache} = whistle_apps_sup:config_cache_proc(),
UpdateFun = fun(J) ->
NodeConfig = wh_json:get_value(Node, J, wh_json:new()),
Please sign in to comment.
Something went wrong with that request. Please try again.