vertx-lang-kotlin icon indicating copy to clipboard operation
vertx-lang-kotlin copied to clipboard

why executeBlockingAwait return type is nullable?

Open rainmanhhh opened this issue 6 years ago • 2 comments

executeBlockingAwait calls awaitResult If awaitResult failed, it will throw an exception instead of return null The return type should be [T] but not [T?]

rainmanhhh avatar Dec 06 '19 02:12 rainmanhhh

I don't see null as synonymous with failure; some methods have @Nullable results, for example:

  • io.vertx.redis.client.RedisAPI
    default RedisAPI append(String arg0, String arg1, Handler<AsyncResult<@Nullable Response>> handler) {
      send(Command.APPEND, arg0, arg1).setHandler(handler);
      return this;
    }
    
  • io.vertx.kotlin.redis.client.RedisAPI
    suspend fun RedisAPI.appendAwait(arg0: String, arg1: String): Response? {
      return awaitResult {
        this.append(arg0, arg1, it)
      }
    }
    

rgmz avatar Dec 09 '19 23:12 rgmz

NOTE: the parameter is [T] but not [T: Any] so if the action return value is actually nullable(eg. [Response?]), just call it like this: executeBlockingAwait<Response?>(...) [Response?] can be omitted

rainmanhhh avatar Dec 10 '19 23:12 rainmanhhh

The return type is T? because when the call succeeds, the result can be null.

tsegismont avatar Dec 08 '22 17:12 tsegismont