okhttp: Fix AsyncSink.close() NPE

This fixes a regression introduced in e96d0477. The NullPointerException
only happens on client-side when some other error occurred during
handshaking.

I tried to add a test, but SerializingExecutor catches+logs the
exception and the expected behavior in the circumstance is that close()
is a noop. So the NPE was entirely benign other than annoying log
messages.
This commit is contained in:
Eric Anderson 2022-07-06 13:06:01 -07:00
parent 3de7e74c57
commit e767905f4a
1 changed files with 1 additions and 1 deletions

View File

@ -208,7 +208,7 @@ final class AsyncSink implements Sink {
@Override
public void run() {
try {
if (buffer.size() > 0) {
if (sink != null && buffer.size() > 0) {
sink.write(buffer, buffer.size());
}
} catch (IOException e) {