javavert.xvertx-verticlevertx-httpclient

Java Vert.x - Getting Result is already complete: succeeded Error


I am trying to perform multiple database actions in my vertx code but for some reason I get this error

Aug 18, 2021 12:20:09 PM io.vertx.core.impl.ContextImpl SEVERE: Unhandled exception java.lang.IllegalStateException: Result is already complete: succeeded at io.vertx.core.impl.FutureImpl.fail(FutureImpl.java:126) at com.himman.dao.ReturnRawmatToCompanyDAO.lambda$31(ReturnRawmatToCompanyDAO.java:801) at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:327) at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366) at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)

My code looks like so. Can someone please help.

public Future<String> delete(String id)
{
        Promise<String> deleted = Promise.promise();
        
        delete_1(id).onComplete(handler -> {
            delete_2(id).onComplete(handler_1 -> {
                delete_3_InvRaw_Mfg(handler_1.result()).onComplete(handler_2 -> {
                    delete_4_InvRaw_Company(handler_1.result()).onComplete(handler_3 -> {
                        deleted.complete(id);                       
                    });
                    
                });
            });
        });
        return deleted.future();
}

Solution

  • You are trying to complete a future/Promise which is already completed. From your code, I would suspect that it is the deleted.complete(id);.

    Like pointed by @tsegismont, the code seems more complete than this.

    From doc

    Throws: IllegalStateException - when the promise is already completed