NullpointerException on downloadFile (starts with version 0.34)
DevMaddin opened this issue · comments
We use SSHJ to download files from a SFTP-Server and used a long time the version 0.19.
Now we upgrade to version 0.36 and become a NullpointerException on downloading a file.
I tested other versions and the version 0.33 works but with 0.34 the Nullpointer is thrown.
Any ideas what has changed in version 0.34 and not working with our code?
Update:
I found the Nullpointer in the Implementation of "InMemoryDestFile":
What is the correct Implementation for "getLength()" and "getOutputStream(boolean append)"?
The StreamingInMemoryDestFile
is not part of SSHJ.
The method that contains line 172 which you indicate contains the following code in 0.34.0:
sshj/src/main/java/net/schmizz/sshj/sftp/SFTPFileTransfer.java
Lines 153 to 178 in ec467a3
This just closes the outputstream that is assigned at L163.
Not sure how that can be null if you're actually indeed passing in that StreamingInMemoryDestFile
Thanks @hierynomus .
My comment "before NULL" means that I returned NULL before. 😅
Now i set "getOutputStream()" and my question is if that is correct and what could the correct Implementation for "getLength()" and "getOutputStream(boolean append)"?
I'd say it depends, I'm not sure you you use the library. The append
flag is there when you're resuming a downloaded file, so with append=true
you'd expect the current implementation that returns the outputStream. With append=false
you would expect to set and return a new or truncated outputstream, so that there's no previous contents.
The getLength
looks fine.
Thanks. I will try it.