Skip to content

Commit 236629e

Browse files
authored
Merge pull request #296 from kafkaex/fix_dialyzer
Fix handle_cast fake return value
2 parents b87732d + 65901be commit 236629e

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

lib/kafka_ex/gen_consumer.ex

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -285,49 +285,56 @@ defmodule KafkaEx.GenConsumer do
285285

286286
def handle_call(msg, _from, consumer_state) do
287287
# taken from the GenServer handle_call implementation
288-
proc = case Process.info(self(), :registered_name) do
289-
{_, []} -> self()
290-
{_, name} -> name
291-
end
288+
proc =
289+
case Process.info(self(), :registered_name) do
290+
{_, []} -> self()
291+
{_, name} -> name
292+
end
292293

293294
# We do this to trick Dialyzer to not complain about non-local returns.
294295
case :erlang.phash2(1, 1) do
295296
0 ->
296-
raise "attempted to call KafkaEx.GenConsumer #{inspect proc} " <>
297-
"but no handle_call/3 clause was provided"
298-
1 -> {:reply, {:bad_call, msg}, consumer_state}
297+
raise "attempted to call KafkaEx.GenConsumer #{inspect(proc)} " <>
298+
"but no handle_call/3 clause was provided"
299+
300+
1 ->
301+
{:reply, {:bad_call, msg}, consumer_state}
299302
end
300303
end
301304

302305
def handle_cast(msg, consumer_state) do
303306
# taken from the GenServer handle_cast implementation
304-
proc = case Process.info(self(), :registered_name) do
305-
{_, []} -> self()
306-
{_, name} -> name
307-
end
307+
proc =
308+
case Process.info(self(), :registered_name) do
309+
{_, []} -> self()
310+
{_, name} -> name
311+
end
308312

309313
# We do this to trick Dialyzer to not complain about non-local returns.
310314
case :erlang.phash2(1, 1) do
311315
0 ->
312316
raise "attempted to cast KafkaEx.GenConsumer #{inspect(proc)} " <>
313-
" but no handle_cast/2 clause was provided"
314-
1 -> {:noreply, {:bad_cast, msg}, consumer_state}
317+
" but no handle_cast/2 clause was provided"
318+
319+
1 ->
320+
{:noreply, consumer_state}
315321
end
316322
end
317323

318324
def handle_info(msg, consumer_state) do
319325
# taken from the GenServer handle_info implementation
320-
proc = case Process.info(self(), :registered_name) do
321-
{_, []} -> self()
322-
{_, name} -> name
323-
end
326+
proc =
327+
case Process.info(self(), :registered_name) do
328+
{_, []} -> self()
329+
{_, name} -> name
330+
end
324331

325332
pattern = '~p ~p received unexpected message in handle_info/2: ~p~n'
326333
:error_logger.error_msg(pattern, [__MODULE__, proc, msg])
327334
{:noreply, consumer_state}
328335
end
329336

330-
defoverridable [init: 2, handle_call: 3, handle_cast: 2, handle_info: 2]
337+
defoverridable init: 2, handle_call: 3, handle_cast: 2, handle_info: 2
331338
end
332339
end
333340

0 commit comments

Comments
 (0)