This repository has been archived by the owner on Dec 7, 2019. It is now read-only.
Make readAll() resilient to exceptions reading a single file #296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, if an exception occurs on a
fileSystem.read(s)
call inside theFSAllReader.readAll()
method, then the whole chain will stop with an onError emission. This prevents us from getting subsequent files on the path.This PR proposes a solution to flat map each individual file read, wrapping its observable. If an exception occurs for a file read, then we return a
ReadResultBufferedSource
for that file that wraps the exception.Current known issues:
ReadResultBufferedSource
seems like an unnecessary wrapping of a buffer just to fit the contract of theObservable<BufferedSource> readAll()
method, which requires aBufferedSource
. Ideally, we could return anObservable<ReadResult>
instead which wraps either the exception or theBufferedSource
. This would be, however, an API breaking change.GsonSourceParser
) to returnnull
for an empty buffer. This will throw a NPE on the chain instead of the original exception when reading the file.safeReadAll()
that filters out all the results that came from an exception?This PR fixes #293