Skip to content

Commit d8b67b7

Browse files
Extract common task listener notification code
1 parent c637098 commit d8b67b7

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/com/linkedin/parseq/BaseTask.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,7 @@ private void purgeListeners(State<T> state)
460460
TaskListener taskListener;
461461
while ((taskListener = _taskListeners.poll()) != null)
462462
{
463-
try
464-
{
465-
taskListener.onUpdate(this, trace);
466-
}
467-
catch (Throwable e)
468-
{
469-
LOG.warn("Promise listener threw exception. Ignoring and continuing. Listener: " + taskListener, e);
470-
}
463+
notifyTaskListener(taskListener, trace);
471464
}
472465
}
473466

@@ -492,18 +485,23 @@ private void notifyTaskListeners(State<T> state)
492485
final ShallowTrace trace = buildShallowTrace(state);
493486
for (TaskListener taskListener : _taskListeners)
494487
{
495-
try
496-
{
497-
taskListener.onUpdate(this, trace);
498-
}
499-
catch (Throwable e)
500-
{
501-
LOG.warn("Promise listener threw exception. Ignoring and continuing. Listener: " + taskListener, e);
502-
}
488+
notifyTaskListener(taskListener, trace);
503489
}
504490
}
505491
}
506492

493+
private void notifyTaskListener(TaskListener taskListener, ShallowTrace trace)
494+
{
495+
try
496+
{
497+
taskListener.onUpdate(this, trace);
498+
}
499+
catch (Throwable e)
500+
{
501+
LOG.warn("Task listener threw exception. Ignoring and continuing. Listener: " + taskListener, e);
502+
}
503+
}
504+
507505
private ShallowTrace buildShallowTrace(State<T> state)
508506
{
509507
return state._trace;

0 commit comments

Comments
 (0)