Clarify handling of IOException inside [Read|Write]Listener methods
- Dominant language
- Java
- Stars
- 325
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
This came up while investigating a Tomcat bug report. I'm going to refer to `WriteListener.onWritePossible` but it applies to `ReadListener.onDataAvailable()` and `ReadListener.onAllDataRead()` as well.
A simplified listener implementation may look something like this:
```
public void onWritePossible() throws IOException {
...
do {
sos.write(...);
} while (sos.isReady());
}
```
The question is:
> Is the application permitted to swallow the IOException that may be thrown by `sos.write(...)` in the above code or must it be (re-)thrown from the method for the container code that called `onWritePossible()` to handle?
I can make a case for either approach. I have no strong preference (Tomcat now handles both cases) but I think it would be useful to add some clarification to the Javadoc for these methods to make the expected behaviour here explicit both for container developers and end users.
Contributor guide
Research direction
Start with the Javadoc for WriteListener.onWritePossible(), then compare the corresponding ReadListener methods onDataAvailable() and onAllDataRead(). Clarify whether applications may swallow an IOException or must rethrow it so the container can handle it, and ensure the documented behavior is consistent across these methods.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100