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

EOF flag not set on exhausted input streams. #1340

Closed
mefyl opened this issue Nov 7, 2018 · 2 comments
Closed

EOF flag not set on exhausted input streams. #1340

mefyl opened this issue Nov 7, 2018 · 2 comments
Assignees
Labels
kind: bug release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Milestone

Comments

@mefyl
Copy link
Contributor

mefyl commented Nov 7, 2018

When reaching the end of a stream while parsing JSON, the eofbit is not set.

std::stringstream s;
try { json j ; j >> s; } catch (...) {}
s.eof(); // false

This seems like a reasonable expected behaviour, as our existing code relies of eofbit to determine when the end of a continuous stream of json commands is reached.

mefyl added a commit to mefyl/json that referenced this issue Nov 7, 2018
	Fix issue nlohmann#1340.

        The eofbit is set manually since we don't go through the
	stream interface. We could maybe use the stream interface
	instead, but there are some assumptions regarding which
	exception go through, so this seems to be the most prudent
	approach for now.
mefyl added a commit to mefyl/json that referenced this issue Nov 7, 2018
	Fix issue nlohmann#1340.

        The eofbit is set manually since we don't go through the
	stream interface. We could maybe use the stream interface
	instead, but there are some assumptions regarding which
	exception go through, so this seems to be the most prudent
	approach for now.
@nlohmann
Copy link
Owner

nlohmann commented Nov 8, 2018

Thanks for reporting and thanks for opening a PR! As @gregmarr already pointed out, it is important that subsequent reads from a stream are still working.

mefyl added a commit to mefyl/json that referenced this issue Nov 8, 2018
	Fix issue nlohmann#1340.

        The eofbit is set manually since we don't go through the
	stream interface. We could maybe use the stream interface
	instead, but there are some assumptions regarding which
	exception go through, so this seems to be the most prudent
	approach for now.
@mefyl
Copy link
Contributor Author

mefyl commented Nov 8, 2018

Addressed in #1343.

@nlohmann nlohmann self-assigned this Nov 9, 2018
@nlohmann nlohmann added kind: bug solution: proposed fix a fix for the issue has been proposed and waits for confirmation release item: 🐛 bug fix labels Nov 9, 2018
@nlohmann nlohmann added this to the Release 3.4.1 milestone Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug release item: 🐛 bug fix solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants