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

BlobReadChannel read trows a non-IOException #219

Closed
agrinh opened this issue Mar 30, 2020 · 7 comments · Fixed by #229
Closed

BlobReadChannel read trows a non-IOException #219

agrinh opened this issue Mar 30, 2020 · 7 comments · Fixed by #229
Assignees
Labels
api: storage Issues related to the googleapis/java-storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@agrinh
Copy link

agrinh commented Mar 30, 2020

Couldn't find this discussed anywhere and thought it belonged here, I hope you agree, please let me know otherwise.

BlobReadChannel.read is annotated with @throws IOException which fits the interface and expected behaviour with nio (e.g. I get the expected IOException on read in the standard ReadableBytesChannel interface and in an input stream created with Channels.newInputStream)

However, at least one of the current exceptions thrown is StorageException, which is not an IOException, forcing users to know that this particular ReadbleBytesChannel throws another exception.

Could the exceptions thrown here be modified to inherit from IOException instead?

@chingor13 chingor13 transferred this issue from googleapis/google-cloud-java Mar 31, 2020
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/java-storage API. label Mar 31, 2020
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Mar 31, 2020
@frankyn frankyn added documentation Improvements or additions to documentation type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. and removed type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. triage me I really want to be triaged. documentation Improvements or additions to documentation labels Apr 1, 2020
@frankyn
Copy link
Member

frankyn commented Apr 1, 2020

Hi @agrinh,

Thanks for filing this issue. Looks like this has been an issue for a while now. I think it makes sense to update the exception type, but haven't investigated the implications of making such a change.

How often does this occur?

@dmitry-fa dmitry-fa self-assigned this Apr 2, 2020
@dmitry-fa
Copy link
Contributor

What about introducing new StorageIOException extending IOException?

@frankyn
Copy link
Member

frankyn commented Apr 2, 2020

If it's a bug for the contract to return StorageException, then it should be updated to an IOException to meet expectation. It also avoids the need to support another Exception class.

Additionally, the method has throws IOException so it's a known checked exception for end-users.

@dmitry-fa
Copy link
Contributor

The thrown StorageException used to contain the extra code, fortunately, in case of BlobReadChannel.read() this code is UNKNOWN_CODE, so yes we could safely replace StorageException with IOException without introducing a new exception class.

I'll take care of this.

@frankyn
Copy link
Member

frankyn commented Apr 2, 2020

Thanks @dmitry-fa !

@agrinh
Copy link
Author

agrinh commented Apr 2, 2020

Thanks, that sounds great!

Also, @frankyn sorry for not getting back to you sooner, looks like you don't need any further input now.

@frankyn
Copy link
Member

frankyn commented Apr 2, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants