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.
InputStream.read(byte[] b) can return -1. This value is currently unconditionally used as 3rd parameter for OutputStream.write(byte[] b, int off, int len) - producing an IndexOutOfBoundsException. Actually the current situation creates a race condition. It starts with the response completely read from the InputStream. After a very short time another call to InputStream.read() is invoked. This call blocks, the FIN packet arrives, the TCP connection closes and the method returns with 0. Everything fine. With a very low-latency network the FIN packet arrives before the next call to InputStream.read(). In this scenario the method return -1. Bang! We have observed this issue in a Kubernetes pod with two containers communicating via localhost. One container running the ClamAV REST service (incl. the Clamd Java client) and the other running a clamd instance.