feixiangff commented on issue #86: [bugfix] fix transfer large file bug(more 
than1GB)
URL: https://github.com/apache/mina-sshd/pull/86#issuecomment-454275336
 
 
   Hello, here is the case on my computer
   
   OS:MAC OS 10.10.5(Yosemite)
   JDK:1.8.0_121
   SSHD:org.apache.sshd:sshd-core:2.1.0
   
   How I start sshd server:
   `
   
       private SshServer sshServer;
       public SshDaemon(@Value("${git.server.ip}") String gitServerIP, 
@Value("${git.server.port}") String gitServerPort,
                        @Value("${inet.socket.host}") String inetSocketHost, 
@Value("${inet.socket.port}") Integer inetSocketPort,
                        @Value("${host.key.pem}") String hostKeyPEM) {
           InetSocketAddress addr = new 
InetSocketAddress(inetSocketHost,inetSocketPort);
           sshServer = SshServer.setUpDefaultServer();
           sshServer.setPort(addr.getPort());
           sshServer.setHost(addr.getHostName());
   
           sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
           
sshServer.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE);
           sshServer.setCommandFactory(ProcessShellCommandFactory.INSTANCE);    
//The key point I think in this case
   
   
           try {
               sshServer.start();
           } catch (IOException e) {
               e.printStackTrace();
           }
       }
   `
   
   SCP command:
   scp -P 29418 -r 
username@localhost:/Users/username/Desktop/ubuntu-15.10-desktop-amd64.iso ./
   
   The size of file is 1178386432(1.1GB)
   
   The stacktrace in endless loop
   
        at 
org.apache.sshd.common.util.NumberUtils.getNextPowerOf2(NumberUtils.java:72)
        at 
org.apache.sshd.common.util.buffer.BufferUtils.getNextPowerOf2(BufferUtils.java:505)
        at 
org.apache.sshd.common.util.buffer.ByteArrayBuffer.ensureCapacity(ByteArrayBuffer.java:207)
        at 
org.apache.sshd.common.util.buffer.Buffer.ensureCapacity(Buffer.java:779)
        at 
org.apache.sshd.common.util.buffer.ByteArrayBuffer.putRawBytes(ByteArrayBuffer.java:167)
        at 
org.apache.sshd.server.shell.TtyFilterInputStream.read(TtyFilterInputStream.java:158)
        at java.io.FilterInputStream.read(FilterInputStream.java:107)
        at 
org.apache.sshd.server.shell.InvertedShellWrapper.pumpStream(InvertedShellWrapper.java:246)
        at 
org.apache.sshd.server.shell.InvertedShellWrapper.pumpStreams(InvertedShellWrapper.java:202)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
   
   
   Some var values in stack:
   `
   
        at 
org.apache.sshd.common.util.NumberUtils.getNextPowerOf2(NumberUtils.java:72)
   
           value = 1073741872
           j = 0
   
   `
   
   `
   //The key point I think in this case
   
        at 
org.apache.sshd.common.util.buffer.ByteArrayBuffer.ensureCapacity(ByteArrayBuffer.java:207)
   
           maxSize = 1073741824
           curPos = 1073733680
           remaining = 8144
           minimum = 1073741872
           can not compute var 'actual' since getNextPowerOf2 is in endless loop
   
   `
   
   It seems that this is a bug in ByteArrayBuffer(or TtyFilterInputStream), 
since ByteArrayBuffer seems to cache the whole file(even the file is very 
large) in it's buffer, and never compact the buffer
   
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to