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

Mistake on Javadoc method description (?) #1923

Closed
cfuendev opened this issue Jul 25, 2021 · 2 comments · Fixed by #2122
Closed

Mistake on Javadoc method description (?) #1923

cfuendev opened this issue Jul 25, 2021 · 2 comments · Fixed by #2122

Comments

@cfuendev
Copy link

It appears to me that you've made a mistake on the description of the parseReader​(Reader reader) method of the JsonObject class.

image

You can check said method's doc yourself here

I believe it should be "Parses the specified stream/reader into a parse tree".

I hope that my lack of English/Java knowledge isn't the problem here and I'm not wasting your time.

@eamonnmcmanus
Copy link
Member

Thanks for the report! This is the relevant code of JsonParser.parseReader(Reader):

      JsonReader jsonReader = new JsonReader(reader);
      JsonElement element = parseReader(jsonReader);
      if (!element.isJsonNull() && jsonReader.peek() != JsonToken.END_DOCUMENT) {
        throw new JsonSyntaxException("Did not consume the entire document.");
      }
      return element;

The second line calls JsonParser.parseReader(JsonReader), which does not have a similar check for END_DOCUMENT. It really does return the next value, as its documentation says. It's certainly regrettable that two methods with the same name have such different behaviour, but the javadoc does appear to be correct.

@eamonnmcmanus
Copy link
Member

Actually I think we should clarify the documentation to make it explicit that these methods behave differently despite having the same name.

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

Successfully merging a pull request may close this issue.

2 participants