Skip to content

Determine if it is possible for Service Invoker to catch unhandled errors that handle inside a Async method. #32

Description

@NavidMitchell

The service invoker does not return the error if a method that returns a CompletableFuture encounters an unhandled exception and never completes the future.

I saw this when the code below tried to deserialize the json and failed.

org.kinotic.structures.internal.api.services.sql.DefaultElasticVertxClient Line: 61


public CompletableFuture<TranslateResponse> translateSql(String statement,
                                                             List<?> params){
        VertxCompletableFuture<TranslateResponse> responseFuture = new VertxCompletableFuture<>(vertx);
        JsonObject json = new JsonObject().put("query", statement);
        if(params != null) {
            JsonArray paramsJson = new JsonArray();
            for(Object param : params){
                paramsJson.add(param);
            }
            json.put("params", paramsJson);
        }
        sqlTranslateRequest.sendJsonObject(json, ar -> {
            if(ar.succeeded()){
                TranslateResponse translateResponse = TranslateResponse.of(builder -> {
                    builder.withJson(new ByteArrayInputStream(ar.result()
                                                                .body()
                                                                .getBytes()));
                    return builder;
                });
                responseFuture.complete(translateResponse);
            }else{
                responseFuture.completeExceptionally(ar.cause());
            }
        });
        return responseFuture;
    }
    
    ```

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions