Remove redundant extra lambda in EventManager#fire implementation

This commit is contained in:
Luck
2018-12-04 00:03:47 +00:00
parent 3d3d6adf04
commit 6ff9180987

View File

@@ -110,7 +110,8 @@ public class VelocityEventManager implements EventManager {
return CompletableFuture.completedFuture(event); return CompletableFuture.completedFuture(event);
} }
Runnable runEvent = () -> { CompletableFuture<E> eventFuture = new CompletableFuture<>();
service.execute(() -> {
PostResult result = bus.post(event); PostResult result = bus.post(event);
if (!result.exceptions().isEmpty()) { if (!result.exceptions().isEmpty()) {
logger.error("Some errors occurred whilst posting event {}.", event); logger.error("Some errors occurred whilst posting event {}.", event);
@@ -119,11 +120,6 @@ public class VelocityEventManager implements EventManager {
logger.error("#{}: \n", ++i, exception); logger.error("#{}: \n", ++i, exception);
} }
} }
};
CompletableFuture<E> eventFuture = new CompletableFuture<>();
service.execute(() -> {
runEvent.run();
eventFuture.complete(event); eventFuture.complete(event);
}); });
return eventFuture; return eventFuture;