Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadFactory;
import java.util.function.Consumer;
import java.util.function.Supplier;

import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
Expand Down Expand Up @@ -75,7 +74,7 @@ protected void run()
runTask(task);
}
catch (Throwable t) {
log.error("Error running task on event loop", t);
log.error(t, "Error executing task on event loop");
}
updateLastExecutionTime();
}
Expand All @@ -92,7 +91,7 @@ public void execute(Runnable task, Consumer<Throwable> failureHandler, Scheduler
task.run();
}
catch (Throwable t) {
log.error("Error executing task on event loop", t);
log.error(t, "Error executing method %s on event loop.", methodSignature);
if (failureHandler != null) {
failureHandler.accept(t);
}
Expand All @@ -106,24 +105,5 @@ public void execute(Runnable task, Consumer<Throwable> failureHandler, Scheduler
}
});
}

public <T> void execute(Supplier<T> task, Consumer<T> successHandler, Consumer<Throwable> failureHandler)
{
requireNonNull(task, "task is null");
this.execute(() -> {
try {
T result = task.get();
if (successHandler != null) {
successHandler.accept(result);
}
}
catch (Throwable t) {
log.error("Error executing task on event loop", t);
if (failureHandler != null) {
failureHandler.accept(t);
}
}
});
}
}
}
Loading