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

setIfNotExists does not check if key exist and creates key anyway #379

Open
pzmi opened this issue Jul 26, 2017 · 0 comments
Open

setIfNotExists does not check if key exist and creates key anyway #379

pzmi opened this issue Jul 26, 2017 · 0 comments

Comments

@pzmi
Copy link

pzmi commented Jul 26, 2017

Method setIfNotExists in EtcdClient is implemented like this:
Request.request().methodPUT().key(key).value(value).prevExist(false);
which results in this uri:
/v2/keys/KEY

As you can see there's nothing about previous value, prevExist=true is missing.

prevExist is omitted due to the current uri building implementation which for prevExist looks like this:
in paramBody method:

...
if ( prevExist ) {
    if (!first) builder.append("&");
    builder.append("prevExist=true");
    first=false;
}
...

Imo it should look somewhat like this:
private Boolean prevExist;

public Request prevExist(boolean prevExist) {
    this.prevExist = prevExist;
    return this;
}

in paramBody method:

...
if ( prevExist != null ) {
    if (!first) builder.append("&");
    builder.append("prevExist=");
    builder.append(prevExist);
    first=false;
}
...

Reproduction:
use EtcdClient#setIfNotExists.

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

No branches or pull requests

1 participant