Skip to content

Prevent infinite loop with AbstractCharacterFilterReader if EOF is filtered out#226

Closed
robtimus wants to merge 1 commit into
apache:masterfrom
robtimus:infinite-loop-AbstractCharacterFilterReader
Closed

Prevent infinite loop with AbstractCharacterFilterReader if EOF is filtered out#226
robtimus wants to merge 1 commit into
apache:masterfrom
robtimus:infinite-loop-AbstractCharacterFilterReader

Conversation

@robtimus

Copy link
Copy Markdown
Contributor

AbstractCharacterFilterReader.read() only aborts its loop if filter(ch) returns false. If that method returns true for EOF, you'll get an infinite loop if the backing read() call keeps returning EOF. That's really easy to achieve with CharacterFilterReader.

This small fix aborts the loop not only if filter(ch) returns false, but also if the backing read() call returns EOF.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 89.26% when pulling 153f3d1 on robtimus:infinite-loop-AbstractCharacterFilterReader into 8365dcf on apache:master.

asfgit pushed a commit that referenced this pull request May 12, 2021
filtered out #226.

- Based on PR #226 by Rob Spoor, with an additional (missing) test, and
clean ups.
- Add CharacterSetFilterReader.CharacterSetFilterReader(Reader,
Integer...).
@garydgregory

Copy link
Copy Markdown
Member

@robtimus
I pushed an alternate commit to master, please verify and close this PR if it works for you.

@robtimus

Copy link
Copy Markdown
Contributor Author

@garydgregory
Thanks, the only difference between this PR and master is now a (duplicated) test.

@robtimus robtimus closed this May 12, 2021
@robtimus robtimus deleted the infinite-loop-AbstractCharacterFilterReader branch May 12, 2021 16:07
@garydgregory

Copy link
Copy Markdown
Member

What is duplicated?

@robtimus

Copy link
Copy Markdown
Contributor Author

I had added the testReadFilteringEOF method at the bottom, whereas you added it a bit higher. That didn't trigger any conflicts during rebase, it just added the same method, leading to two methods with the same name and almost the same contents.

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 this pull request may close these issues.

3 participants