Skip to content

Commit

Permalink
AsyncExecutor: use lambda.
Browse files Browse the repository at this point in the history
  • Loading branch information
greenrobot-team committed Dec 8, 2021
1 parent 757bc9a commit 60c4b78
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions EventBus/src/org/greenrobot/eventbus/util/AsyncExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,21 @@ private AsyncExecutor(Executor threadPool, EventBus eventBus, Class<?> failureEv

/** Posts an failure event if the given {@link RunnableEx} throws an Exception. */
public void execute(final RunnableEx runnable) {
threadPool.execute(new Runnable() {
@Override
public void run() {
threadPool.execute(() -> {
try {
runnable.run();
} catch (Exception e) {
Object event;
try {
runnable.run();
} catch (Exception e) {
Object event;
try {
event = failureEventConstructor.newInstance(e);
} catch (Exception e1) {
eventBus.getLogger().log(Level.SEVERE, "Original exception:", e);
throw new RuntimeException("Could not create failure event", e1);
}
if (event instanceof HasExecutionScope) {
((HasExecutionScope) event).setExecutionScope(scope);
}
eventBus.post(event);
event = failureEventConstructor.newInstance(e);
} catch (Exception e1) {
eventBus.getLogger().log(Level.SEVERE, "Original exception:", e);
throw new RuntimeException("Could not create failure event", e1);
}
if (event instanceof HasExecutionScope) {
((HasExecutionScope) event).setExecutionScope(scope);
}
eventBus.post(event);
}
});
}
Expand Down

0 comments on commit 60c4b78

Please sign in to comment.