[ 
https://issues.apache.org/jira/browse/VFS-778?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17449831#comment-17449831
 ] 

Gary D. Gregory commented on VFS-778:
-------------------------------------

[~manishbansal8843] 

I think this was recently fixed in git master by commit
[d2f6f34f9700bd66a226d2ceb1495ac0d4c8f223|https://github.com/apache/commons-vfs/commit/d2f6f34f9700bd66a226d2ceb1495ac0d4c8f223]

May you please try git master or a 2.10.0-SNAPSHOT build?


> SftpFileSystem returning null channel
> -------------------------------------
>
>                 Key: VFS-778
>                 URL: https://issues.apache.org/jira/browse/VFS-778
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 2.4.1, 2.5.0, 2.6.0
>            Reporter: Manish Bansal
>            Priority: Major
>              Labels: pull-request-available
>
> I tested v2.4.1 jar with 8 threads. The purpose was to upload 1.3TB of data 
> on FTP via sftp protocol. There were 850 folders with varying sizes from 10 
> MB to 25GB. After the job was finished, It was observed that 50 folders 
> failed to upload due to null pointer exception as below.
> {code:java}
> java.lang.NullPointerException: null
>         at 
> org.apache.commons.vfs2.provider.sftp.SftpFileObject.doGetOutputStream(SftpFileObject.java:475)
>         at 
> org.apache.commons.vfs2.provider.AbstractFileObject.getOutputStream(AbstractFileObject.java:1239)
>         at 
> org.apache.commons.vfs2.provider.DefaultFileContent.buildOutputStream(DefaultFileContent.java:518)
>         at 
> org.apache.commons.vfs2.provider.DefaultFileContent.getOutputStream(DefaultFileContent.java:404)
>         at 
> org.apache.commons.vfs2.provider.DefaultFileContent.getOutputStream(DefaultFileContent.java:392)
>         at 
> org.apache.commons.vfs2.provider.DefaultFileContent.write(DefaultFileContent.java:753)
>         at 
> org.apache.commons.vfs2.provider.DefaultFileContent.write(DefaultFileContent.java:771)
>         at org.apache.commons.vfs2.FileUtil.copyContent(FileUtil.java:37)
>         at 
> org.apache.commons.vfs2.provider.AbstractFileObject.copyFrom(AbstractFileObject.java:295)
>         at com.infy.task.helper.FTPUploader.uploadToFTP(FTPUploader.java:173)
>         at com.infy.task.helper.FTPUploader.upload(FTPUploader.java:90)
>         at 
> com.infy.task.AssetDownloadAndUploadTask.run(AssetDownloadAndUploadTask.java:57)
>         at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>         at java.lang.Thread.run(Thread.java:748)
> {code}
> Further, I have analysed the code, it is very highly likely that it will 
> return null due to below piece of code.
> {code:java}
> protected ChannelSftp getChannel() throws IOException {
>         try {
>             // Use the pooled channel, or create a new one
>             ChannelSftp channel = null;
>             if (idleChannel != null) {
>                 synchronized (this) {
>             // What will happen if my code comes here and idleChannel is null
>                     if (idleChannel != null) {
>                         channel = idleChannel;
>                         idleChannel = null;
>                     }
>                 }
>             } else {
>                   channel= .. //create channel
>             }
>             // some more code
>             return channel;
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to