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

KVStore: Dot in key didn't work when request a list of keys in a bucket #621

Closed
philmu opened this issue Mar 25, 2022 · 3 comments
Closed

Comments

@philmu
Copy link

philmu commented Mar 25, 2022

OS: Linux
Nats-Server: 2.6.6
jnats: 2.14.0

// io.nats.client.Connection connection = ...;

final KeyValue bucket = connection.keyValue("bucketname");
bucket.put("Part1.Part2", "value".getBytes());
bucket.get("Part1.Part2").getValue(); // Works. Returns byte[] with 'value' as expected
for (String key : bucket.keys())
{
     System.out.println(key); // Returns 'Part1', Expected 'Part1.Part2'
}

I think here is a problem: https://github.com/nats-io/nats.java/blob/main/src/main/java/io/nats/client/support/NatsKeyValueUtil.java#L80

Possible solutions:

  • Disallow dots in keys
  • expand key with additional elements from split[] (NatsKeyValueUtil.java#L80)
@philmu philmu changed the title KVStore: Dot in Key didn't work when request a list of keys in a bucket KVStore: Dot in key didn't work when request a list of keys in a bucket Mar 25, 2022
@scottf
Copy link
Contributor

scottf commented Mar 25, 2022

Good catch. dots are valid so fixed parsing. #622

@philmu
Copy link
Author

philmu commented Mar 25, 2022

@scottf
Thank you for the fast reply! Code-Change and test looks good. I hadn't noticed, that kve.getKey() also returns a wrong value. 👍

@scottf
Copy link
Contributor

scottf commented Mar 25, 2022

yeah, get key just wraps the .key

public String getKey() { return bucketAndKey.key; }

@philmu philmu closed this as completed Mar 26, 2022
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

2 participants