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

ClassCastException when using RangeLimitOptions #8

Closed
aesteve opened this issue May 18, 2015 · 1 comment

Comments

2 participants
@aesteve
Copy link

commented May 18, 2015

Simply :

RangeLimitOptions options = new RangeLimitOptions();
options.setLimit(0,1);
redis.zrangebyscore("yourkey", "-inf", "+inf", options, result -> {
    // whatever
});

Will fail with a ClassCastException : Long cannot be cast to String.

Because of the cast here : https://github.com/vert-x3/vertx-redis-client/blob/master/src/main/java/io/vertx/redis/op/RangeLimitOptions.java#L49

which is invoked on two Longs : https://github.com/vert-x3/vertx-redis-client/blob/master/src/main/java/io/vertx/redis/op/LimitOptions.java#L49-L50

Maybe we could simply fix it by replacing :

  public JsonArray toJsonArray() {
    JsonArray json = new JsonArray();
    if (withscores != null && withscores) {
      json.add("WITHSCORES");
    }

    for (Object item: super.toJsonArray()) {
      json.add((String) item);
    }
    return json;
  }

with

  public JsonArray toJsonArray() {
    JsonArray json = new JsonArray();
    if (withscores != null && withscores) {
      json.add("WITHSCORES");
    }

    for (Object item: super.toJsonArray()) {
      if (item != null) {
          json.add(item.toString());
      }
    }
    return json;
  }

But idk, maybe we just don't need strings everytime ? :\

purplefox added a commit that referenced this issue Jun 5, 2015

@purplefox

This comment has been minimized.

Copy link
Contributor

commented Jun 5, 2015

fixed

@purplefox purplefox closed this Jun 5, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.