diff options
| author | Michael Davis <mcarsondavis@gmail.com> | 2023-04-14 14:51:27 -0500 |
|---|---|---|
| committer | Diana Parra Corbacho <dparracorbac@vmware.com> | 2023-05-12 11:31:16 +0200 |
| commit | 20f0dd5b070e055a1b5520458b31189dd05637e8 (patch) | |
| tree | 03ccdfc71ba0b0b0cf9dce51f428729aeea51fe5 | |
| parent | fb3d06d05444700e7f986d01c7202466095e66cb (diff) | |
| download | rabbitmq-server-git-20f0dd5b070e055a1b5520458b31189dd05637e8.tar.gz | |
Fix dialyzer errors in rabbit application
This commit has three fixes that make the dialyzer tests pass for the
rabbit app:
* 'pick_node_in_cluster/1' is only called by a function which asserts
that the cluster list is non-empty, so the assertion could never
fail. I've replaced the assertion with an equivalent pattern match in
the function head.
* 'get_sys_status/1' will fail in its call to 'sys:get_status/1'
according to the typespec but not in practice when passed a Ra
server ID ('ra:server_id()' type). I added no-warn attributes to
suppress those warnings.
* 'check_cluster_consistency/0' would throw its error but the caller
could handle and bubble-up the error tuple. I have changed it to
return the error tuple.
| -rw-r--r-- | deps/rabbit/src/rabbit_khepri.erl | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/deps/rabbit/src/rabbit_khepri.erl b/deps/rabbit/src/rabbit_khepri.erl index 9f4aa16840..f712505abc 100644 --- a/deps/rabbit/src/rabbit_khepri.erl +++ b/deps/rabbit/src/rabbit_khepri.erl @@ -94,6 +94,11 @@ -compile({no_auto_import, [get/1, get/2, nodes/0]}). +%% `sys:get_status/1''s spec only allows `sys:name()' but can work on any +%% `erlang:send_destination()' including a `ra:server_id()'. +-dialyzer({nowarn_function, get_sys_status/1}). +-dialyzer({no_match, [status/0, cluster_status_from_khepri/0]}). + -define(RA_SYSTEM, coordination). -define(RA_CLUSTER_NAME, metadata_store). -define(RA_FRIENDLY_NAME, "RabbitMQ metadata store"). @@ -157,8 +162,7 @@ add_member(JoiningNode, [_ | _] = Cluster) -> {ok, already_member} end. -pick_node_in_cluster(Cluster) when is_list(Cluster) -> - ?assertNotEqual([], Cluster), +pick_node_in_cluster([_ | _] = Cluster) when is_list(Cluster) -> ThisNode = node(), case lists:member(ThisNode, Cluster) of true -> ThisNode; @@ -404,6 +408,7 @@ status() -> end end || N <- Nodes]. + get_sys_status(Proc) -> try lists:nth(5, element(4, sys:get_status(Proc))) of Sys -> {ok, Sys} @@ -540,7 +545,7 @@ check_cluster_consistency() -> {error, not_found} -> ok; {error, _} = E -> - throw(E) + E end. nodes_excl_me(Nodes) -> Nodes -- [node()]. |
