Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebClient] ResponsePredicate create type no found #186

Closed
pcariel opened this issue Apr 3, 2019 · 6 comments · Fixed by #195
Closed

[WebClient] ResponsePredicate create type no found #186

pcariel opened this issue Apr 3, 2019 · 6 comments · Fixed by #195
Assignees
Milestone

Comments

@pcariel
Copy link

pcariel commented Apr 3, 2019

package io.unknow.client;

import io.vertx.reactivex.core.buffer.Buffer;
import io.vertx.reactivex.ext.web.client.HttpResponse;
import io.vertx.reactivex.ext.web.client.predicate.ErrorConverter;
import io.vertx.reactivex.ext.web.client.predicate.ResponsePredicate;

public class UnknowClientPredicate {

  public final static ResponsePredicate predicate = ResponsePredicate.create(
    ResponsePredicate.SC_SUCCESS, ErrorConverter.createFullBody(result -> {
      HttpResponse<Buffer> response = result.response();
      if (response.getHeader("content-type").equals("application/json"));
      return new Exception();
    }));
}

Wrong 1st argument type. Found: 'io.vertx.reactivex.ext.web.client.predicate.ResponsePredicate', required: 'java.util.function.Function<io.vertx.reactivex.ext.web.client.HttpResponse<java.lang.Void>,io.vertx.reactivex.ext.web.client.predicate.ResponsePredicateResult>'

Hello everyone, I need your help.
Excuse me for my bad English

@tsegismont tsegismont added this to the 3.7.1 milestone Apr 4, 2019
@tsegismont tsegismont self-assigned this Apr 4, 2019
@tsegismont
Copy link
Contributor

@pcariel good catch

This is due to a limitation in vertx-codegen. I'll check with @vietj how to solve it. In the meantime, here's a workaround:

    ResponsePredicate predicate = ResponsePredicate.create(response -> {
      return ResponsePredicateResult.newInstance(ResponsePredicate.JSON.getDelegate().apply(response.getDelegate()));
    }, ErrorConverter.createFullBody(result -> {
      HttpResponse<Buffer> response = result.response();
      if (response.getHeader("content-type").equals("application/json")) ;
      return new Exception();
    }));

@tsegismont
Copy link
Contributor

@vietj similar to eclipse-vertx/vertx-codegen#252 in fact. We need to support Function in codegen, in addition to Iterable and Iterator.

@vietj
Copy link
Contributor

vietj commented May 7, 2019

I think that might go beyond what we want to do.

@tsegismont
Copy link
Contributor

I think that might go beyond what we want to do.

Why? How is it different from checking if an API object implements Iterator or Iterable?

If we don't do this, what do you suggest to solve this issue?

@vietj
Copy link
Contributor

vietj commented May 7, 2019

yes I see what you mean better, so in practice io.vertx.reactivex.ext.web.client.predicate.ResponsePredicate should extend Function and that is what we are missing right ?

@tsegismont
Copy link
Contributor

Exactly

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

Successfully merging a pull request may close this issue.

3 participants