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

Inspect our Usage of InterruptedIOException in Java #3322

Open
InsertCreativityHere opened this issue Jan 8, 2025 · 0 comments
Open

Inspect our Usage of InterruptedIOException in Java #3322

InsertCreativityHere opened this issue Jan 8, 2025 · 0 comments

Comments

@InsertCreativityHere
Copy link
Member

InsertCreativityHere commented Jan 8, 2025

At least some (maybe all) of the places where we catch this exception are probably dead code.
For example in StreamSocket:

while (buf.hasRemaining()) {
try {
int ret = _fd.read(buf);
if (ret == -1) {
throw new ConnectionLostException();
} else if (ret == 0) {
return read;
}
read += ret;
} catch (java.io.InterruptedIOException ex) {
continue;
} catch (java.io.IOException ex) {
throw new ConnectionLostException(ex);
}
we have an explicit catch block for this exception but we only call a single method, and according to both the docs and the source code, this exception is never thrown by it.

The Java tooling probably isn't smart enough to detect that this is dead code though because the signature for read is technically just throws IOException, which InterruptedIOException is a subclass of. But, probably still dead in actuality.

@InsertCreativityHere InsertCreativityHere added this to the 3.8.0 milestone Jan 8, 2025
@InsertCreativityHere InsertCreativityHere changed the title Inspect our Usafe of InterruptedIOException in Java Inspect our Usage of InterruptedIOException in Java Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant