question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty StringBuilder causes No state found: INIT EOF

See original GitHub issue

Hi guys

I was doing unit test on my application and I discovered that sending a empty StringBuilder causes a crash. I think that you be good to detect it before start the parsing and then, return a empty JsonObject or JsonArray.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
haskellcamargocommented, Aug 18, 2017

Almost every parser of JSON will throw unexpected end of input. A JSON parser will look for a valid start token, such as STRING, TRUE, FALSE, OPEN_BRACE, OPEN_BRACKET or QUOTE. But, in that case, after trying all these, the found token was EOF, therefore it was unexpected.

It’s default behavior, as you can see on Chrome default JavaScript implementation. 2017-08-18-165305_374x97_scrot

2reactions
haskellcamargocommented, Aug 18, 2017

The behavior is correct, @ppamorim. According to any JSON RFC specification, the first entry must be a JSON-valid expression. Empty string is a syntax error. No matches for ", {, [, \d, true, false or any other valid start token.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reading a web page in Java IOException Premature EOF
This may be because you are reading the content line by line and for the last line the file may be missing a...
Read more >
StringBuilder (Java Platform SE 8 ) - Oracle Help Center
A mutable sequence of characters. This class provides an API compatible with StringBuffer , but with no guarantee of synchronization.
Read more >
How to Check if StringBuilder Is Empty - Code Maze
Check if StringBuilder Is Empty Using the Length Property​​ The StringBuilder class has a property named Length that shows how many Char objects ......
Read more >
Bug descriptions — spotbugs 4.7.3 documentation
This implementation of equals(Object) violates the contract defined by java.lang.Object.equals() because it does not check for null being passed as the argument ...
Read more >
java.io.EOFException - How to solve EOFException - 2022
In this tutorial we will discuss about the EOFException in Java. This exception indicates the the end of file (EOF), or the end...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found