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

ByteSequence toString ? #399

Closed
vorburger opened this issue Sep 18, 2018 · 4 comments
Closed

ByteSequence toString ? #399

vorburger opened this issue Sep 18, 2018 · 4 comments

Comments

@vorburger
Copy link
Member

For debugging, I've found it sometimes useful to log the ByteSequence of a KV.

Our io.etcd.jetcd.data.ByteSequence currently does not implement java.lang.Object.toString().

I have therefore implemented this helper utility for this (see also its usage in ByteSequencesTest), and was wondering if a contribution with that here would be welcome?

Keys (and Values) of course may well contain arbitrary byte sequences. The escaping I implemented is more meant to "look nice, and compact, in logs" than being a reliable bi-directional "codec" (i.e. my goal was only to be able to go from byte[] to readable text, NOT to come up with a representation where said text can be re-transformed into a byte[]). It looks like e.g. «A·00B·FF» for 4 bytes ('A', 0 b, 'B', FF b).

PS: ByteSequence does have a toString(Charset) but that is not for debug logging, and perhaps should have instead better be named getString(), like its getBytes(), or even asString(), but it's already too late for that now, I guess?)

PPS: Perhaps etcdctl ls could print using the same format? I'll file an issue there.

@lburgazzoli
Copy link
Collaborator

@vorburger we could ad an toHexString ?

@adamlehenbauer
Copy link

toHextString wouldn't really help because that's not in the java.lang.Object contract.

My vote would be for a toString() that uses the platform default CHARSET to transform.

@Hendrik-H
Copy link

I don't think platform default is a good choice in a cluster application. I would either use UTF-8, make it configurable or return a hey string from toString.

@github-actions
Copy link

github-actions bot commented Jun 2, 2020

This issue is stale because it has been open 60 days with no activity.
Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Jun 2, 2020
@github-actions github-actions bot closed this as completed Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants