summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-05-19 15:23:13 +0200
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-05-19 15:23:13 +0200
commit12d5f16547a1e9a18d6e144103ead2e8108d7e95 (patch)
tree5409f2da1ad9804b63e059cb86b11555fd19cfb0
parentd9e3d7e8acaf407904924685e76ecb53f8398c95 (diff)
downloadrabbitmq-server-git-12d5f16547a1e9a18d6e144103ead2e8108d7e95.tar.gz
Fix several type specs
The most significant one is the type spec of `gm_pids` in the amqqueue records. I'm surprised Dialyzer didn't say anything about it. However it was reported by Dialyzer in `v3.7.x`.
-rw-r--r--src/amqqueue.erl8
-rw-r--r--src/amqqueue_v1.erl12
-rw-r--r--src/rabbit_amqqueue.erl4
3 files changed, 11 insertions, 13 deletions
diff --git a/src/amqqueue.erl b/src/amqqueue.erl
index 98c666e78e..7f3607a9d5 100644
--- a/src/amqqueue.erl
+++ b/src/amqqueue.erl
@@ -111,7 +111,7 @@
%% implicit
%% update
%% as above
- gm_pids = [] :: [{pid(), pid()} | pid()] | none | '_', %% transient
+ gm_pids = [] :: [{pid(), pid()}] | none | '_', %% transient
decorators :: [atom()] | none | undefined | '_', %% transient,
%% recalculated
%% as above
@@ -137,7 +137,7 @@
recoverable_slaves :: [atom()] | none,
policy :: binary() | none | undefined,
operator_policy :: binary() | none | undefined,
- gm_pids :: [pid()] | none,
+ gm_pids :: [{pid(), pid()}] | none,
decorators :: [atom()] | none | undefined,
state :: atom() | none,
policy_version :: non_neg_integer(),
@@ -438,14 +438,14 @@ get_exclusive_owner(Queue) ->
% gm_pids
--spec get_gm_pids(amqqueue()) -> [{pid(), pid()} | pid()] | none.
+-spec get_gm_pids(amqqueue()) -> [{pid(), pid()}] | none.
get_gm_pids(#amqqueue{gm_pids = GMPids}) ->
GMPids;
get_gm_pids(Queue) ->
amqqueue_v1:get_gm_pids(Queue).
--spec set_gm_pids(amqqueue(), [{pid(), pid()} | pid()] | none) -> amqqueue().
+-spec set_gm_pids(amqqueue(), [{pid(), pid()}] | none) -> amqqueue().
set_gm_pids(#amqqueue{} = Queue, GMPids) ->
Queue#amqqueue{gm_pids = GMPids};
diff --git a/src/amqqueue_v1.erl b/src/amqqueue_v1.erl
index b8063c6d6c..220d2c43e1 100644
--- a/src/amqqueue_v1.erl
+++ b/src/amqqueue_v1.erl
@@ -90,8 +90,6 @@
qnode/1,
macros/0]).
--dialyzer({nowarn_function, is_quorum/1}).
-
-define(record_version, ?MODULE).
-define(is_backwards_compat_classic(T),
(T =:= classic orelse T =:= ?amqqueue_v1_type)).
@@ -113,7 +111,7 @@
%% implicit
%% update
%% as above
- gm_pids = [] :: [pid()] | none | '_', %% transient
+ gm_pids = [] :: [{pid(), pid()}] | none | '_', %% transient
decorators :: [atom()] | none | undefined | '_', %% transient,
%% recalculated
%% as above
@@ -137,7 +135,7 @@
recoverable_slaves :: [atom()] | none,
policy :: binary() | none | undefined,
operator_policy :: binary() | none | undefined,
- gm_pids :: [pid()] | none,
+ gm_pids :: [{pid(), pid()}] | none,
decorators :: [atom()] | none | undefined,
state :: atom() | none,
policy_version :: non_neg_integer(),
@@ -289,7 +287,7 @@ new_with_version(?record_version,
rabbit_framing:amqp_table(),
rabbit_types:vhost() | undefined,
map(),
- ?amqqueue_v1_type) -> amqqueue().
+ ?amqqueue_v1_type | classic) -> amqqueue().
new_with_version(?record_version,
#resource{kind = queue} = Name,
@@ -367,11 +365,11 @@ get_exclusive_owner(#amqqueue{exclusive_owner = Owner}) -> Owner.
% gm_pids
--spec get_gm_pids(amqqueue()) -> [{pid(), pid()} | pid()] | none.
+-spec get_gm_pids(amqqueue()) -> [{pid(), pid()}] | none.
get_gm_pids(#amqqueue{gm_pids = GMPids}) -> GMPids.
--spec set_gm_pids(amqqueue(), [{pid(), pid()} | pid()] | none) -> amqqueue().
+-spec set_gm_pids(amqqueue(), [{pid(), pid()}] | none) -> amqqueue().
set_gm_pids(#amqqueue{} = Queue, GMPids) ->
Queue#amqqueue{gm_pids = GMPids}.
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index bb6fd2932e..7d1837550a 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -1428,12 +1428,12 @@ stat(Q) when ?amqqueue_is_quorum(Q) -> rabbit_quorum_queue:stat(Q);
stat(Q) -> delegate:invoke(amqqueue:get_pid(Q), {gen_server2, call, [stat, infinity]}).
-spec pid_of(amqqueue:amqqueue()) ->
- {'ok', pid()} | rabbit_types:error('not_found').
+ pid().
pid_of(Q) -> amqqueue:get_pid(Q).
-spec pid_of(rabbit_types:vhost(), rabbit_misc:resource_name()) ->
- {'ok', pid()} | rabbit_types:error('not_found').
+ pid() | rabbit_types:error('not_found').
pid_of(VHost, QueueName) ->
case lookup(rabbit_misc:r(VHost, queue, QueueName)) of