Fix InputStreamByteChunkProvider#isAvailable#850
Fix InputStreamByteChunkProvider#isAvailable#850vorobii-vitalii wants to merge 5 commits intohierynomus:masterfrom
Conversation
|
@hierynomus Any news?? |
|
@vorobii-vitalii As you noticed using the |
|
Hi, @laeubi Perhaps function name can be improved |
|
And I am not sure we can avoid this polling loop, we have to read from file/socket in chunks, because otherwise we might run into out of memory error |
It does not, per javadoc it might return an estimate it is also legal to just return 0 and this is the case you are encountering here. So this PR actually makes
The provider need to know if there is more to write but this should not result in using available on an input stream! Instead it should work similar to how |
…che and include read byte
I agree that my solution changes semantics of this function, implemented different approach |
laeubi
left a comment
There was a problem hiding this comment.
I think this is a much better approach, just some style comments.
src/main/java/com/hierynomus/smbj/io/BufferedInputStreamReader.java
Outdated
Show resolved
Hide resolved
src/main/java/com/hierynomus/smbj/io/BufferedInputStreamReader.java
Outdated
Show resolved
Hide resolved
src/main/java/com/hierynomus/smbj/io/BufferedInputStreamReader.java
Outdated
Show resolved
Hide resolved
src/main/java/com/hierynomus/smbj/io/BufferedInputStreamReader.java
Outdated
Show resolved
Hide resolved
|
Before I merge this change in. I'd like to see a testcase that proves the original implementation wrong. |
|
@hierynomus there is already a testcase in this PR, @vorobii-vitalii does this testcase fails without your patch? |
|
I've seen the testcase indeed, I'm not convinced it fails without. |
|
@hierynomus @laeubi Hey guys! Is PR still missing some changes required for merge? |
laeubi
left a comment
There was a problem hiding this comment.
It looks good to me but I'm not a committer on the project :-)
| private final BufferedInputStream inputStream; | ||
| private volatile int cachedByte = EOF; | ||
|
|
||
| public BufferedInputStreamReader(BufferedInputStream inputStream) { |
There was a problem hiding this comment.
Does it really requires a BufferedInputStream here? If not then a plain InputStream would make this clas more reusable
|
Hello @hierynomus Please let me know what changes are missing in this PR. |


Hello!
There is issue in this function -
smbj/src/main/java/com/hierynomus/smbj/io/InputStreamByteChunkProvider.java
Line 53 in b78c872
According to docs - https://docs.oracle.com/javase/8/docs/api/java/io/BufferedInputStream.html. BufferedInputStream#available returns only estimate of the number of bytes that can be read.
And one of implementations of InputStream we rely on actually always returns zero before reading.
Please review my approach. I've tested it and it works as expected