Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Added Format.Builtin.toString() as they tend to show up in exception.#87

Merged
wu-sheng merged 5 commits intoopentracing:masterfrom
sjoerdtalsma:builtin-format-tostring
Feb 22, 2017
Merged

Added Format.Builtin.toString() as they tend to show up in exception.#87
wu-sheng merged 5 commits intoopentracing:masterfrom
sjoerdtalsma:builtin-format-tostring

Conversation

@sjoerdtalsma
Copy link
Copy Markdown
Contributor

For example, using Brave with Jersey, the following exception message showed up:

org.glassfish.jersey.server.ContainerException: java.lang.AssertionError:
no registered extractor for io.opentracing.propagation.Format$Builtin@427bb79a

* @return Short name for built-in formats as they tend to show up in exception messages.
*/
@Override
public String toString() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be cleaner to define a private constructor that accepts a String name parameter and toString simply returns the name. It would also fix the leak in this class - its called "Buildin", but people can create more instances of it, which wasn't the intention.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I wasn't sure whether the public constructor was intentional.
In this case, I would propose changing Builtin to an enum, which automatically also fixes the toString() issue!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, enum is not possible due to the Format generic.
Made the constructor private instead.

@bhs
Copy link
Copy Markdown
Contributor

bhs commented Jan 12, 2017

LGTMToo. Thanks @sjoerdtalsma and @yurishkuro .

*/
@Override
public String toString() {
return "Builtin." + name;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw. you can do: return Builtin.class.getSimpleName() + "." + name;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjoerdtalsma do you want to make this change or should we merge this PR? thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bensigelman Thanks for the mention; I'll modify the PR; this change is trivial, looks like I missed @pavolloffay 's comment..

@sjoerdtalsma
Copy link
Copy Markdown
Contributor Author

sjoerdtalsma commented Feb 22, 2017

Last activity on this PR is over a week ago and there have been releases of opentracing-java since.
Any reason this didn't get merged?

@wu-sheng wu-sheng merged commit 7a61a55 into opentracing:master Feb 22, 2017
@wu-sheng
Copy link
Copy Markdown
Member

@sjoerdtalsma merged, seem good enough. Thanks!!

@sjoerdtalsma sjoerdtalsma deleted the builtin-format-tostring branch February 22, 2017 15:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants