mirror of
https://github.com/jlengrand/vert.x.git
synced 2026-03-10 08:51:19 +00:00
Use right future style in MessageProducerImpl
This commit is contained in:
@@ -17,6 +17,7 @@ import io.vertx.core.Handler;
|
||||
import io.vertx.core.Promise;
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.core.eventbus.*;
|
||||
import io.vertx.core.impl.ContextInternal;
|
||||
import io.vertx.core.impl.VertxInternal;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
@@ -153,21 +154,18 @@ public class MessageProducerImpl<T> implements MessageProducer<T> {
|
||||
|
||||
@Override
|
||||
public Future<Void> close() {
|
||||
Promise<Void> promise = Promise.promise();
|
||||
close(promise);
|
||||
return promise.future();
|
||||
if (creditConsumer != null) {
|
||||
return creditConsumer.unregister();
|
||||
} else {
|
||||
return ((ContextInternal)vertx.getOrCreateContext()).succeededFuture();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(Handler<AsyncResult<Void>> handler) {
|
||||
if (creditConsumer != null) {
|
||||
creditConsumer.unregister(handler);
|
||||
} else {
|
||||
vertx.runOnContext(v -> {
|
||||
if (handler != null) {
|
||||
handler.handle(Future.succeededFuture());
|
||||
}
|
||||
});
|
||||
Future<Void> fut = close();
|
||||
if (handler != null) {
|
||||
fut.setHandler(handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user