FTP Client Issue

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

FTP Client Issue

Tony Thompson
I am using the FTP client and I am starting a large file download
using:

public synchronized InputStream startGet(String remoteName)

If I close that InputStream before I read the entire thing (i.e. cancel
the download), I can't use that FTP connection for anything.  I get the
following exception (from Jetty 5.1 FTP client):

java.io.IOException: Pipe closed
        at java.io.PipedInputStream.receive(Unknown Source)
        at java.io.PipedInputStream.receive(Unknown Source)
        at java.io.PipedOutputStream.write(Unknown Source)
        at org.mortbay.util.IO.copy(IO.java:155)
        at org.mortbay.util.IO.copy(IO.java:93)
        at org.mortbay.ftp.DataPort.handle(DataPort.java:289)
        at org.mortbay.ftp.DataPort.run(DataPort.java:168)

Can the FTP client be fixed so that it catches this and aborts the
download or is there something that I should be doing to handle this?  I
have tried catching the exception and doing an abort() and that doesn't
seem to do the trick.

Thanks
Tony


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: FTP Client Issue

Greg Wilkins-5

Tony,

I just had a quick inspection of the code, and it does look to me like
the DataPort should be terminated correctly after such an exception?

How are you seeing this stack trace?  In a debug output or as
a jvm thread report?

Have your tried closing and reopening the Ftp instance?

Could you perhaps run this in a debugger and trace the handling of
this exception?

cheers



Tony Thompson wrote:

> I am using the FTP client and I am starting a large file download
> using:
>
> public synchronized InputStream startGet(String remoteName)
>
> If I close that InputStream before I read the entire thing (i.e. cancel
> the download), I can't use that FTP connection for anything.  I get the
> following exception (from Jetty 5.1 FTP client):
>
> java.io.IOException: Pipe closed
>         at java.io.PipedInputStream.receive(Unknown Source)
>         at java.io.PipedInputStream.receive(Unknown Source)
>         at java.io.PipedOutputStream.write(Unknown Source)
>         at org.mortbay.util.IO.copy(IO.java:155)
>         at org.mortbay.util.IO.copy(IO.java:93)
>         at org.mortbay.ftp.DataPort.handle(DataPort.java:289)
>         at org.mortbay.ftp.DataPort.run(DataPort.java:168)
>
> Can the FTP client be fixed so that it catches this and aborts the
> download or is there something that I should be doing to handle this?  I
> have tried catching the exception and doing an abort() and that doesn't
> seem to do the trick.
>
> Thanks
> Tony
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support
>



-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: FTP Client Issue

Tony Thompson
In reply to this post by Tony Thompson
Here is a simple application that demonstrates the issue:

import java.io.InputStream;

import java.net.InetAddress;

import org.mortbay.ftp.Ftp;

public class FtpTest {
    public static void main(String[] args)
        throws Throwable {

        Ftp ftp = new Ftp( InetAddress.getByName( args[0] ), args[1],
args[2] );

        System.out.println( ftp.list() );
        InputStream in = ftp.startGet( args[3] );
        in.read();
        in.close();

//        ftp.close();
//        ftp.open( InetAddress.getByName( args[0] ) );
//        ftp.authenticate( args[1], args[2] );

        System.out.println( ftp.list() );

        ftp.close();
    }
}

If you attempt to close and reopen the connection (uncomment the three
lines), it hangs the thread.

Tony

>>> [hidden email] 05/30/05 02:22AM >>>

Tony,

I just had a quick inspection of the code, and it does look to me like
the DataPort should be terminated correctly after such an exception?

How are you seeing this stack trace?  In a debug output or as
a jvm thread report?

Have your tried closing and reopening the Ftp instance?

Could you perhaps run this in a debugger and trace the handling of
this exception?

cheers



Tony Thompson wrote:
> I am using the FTP client and I am starting a large file download
> using:
>
> public synchronized InputStream startGet(String remoteName)
>
> If I close that InputStream before I read the entire thing (i.e.
cancel
> the download), I can't use that FTP connection for anything.  I get
the

> following exception (from Jetty 5.1 FTP client):
>
> java.io.IOException: Pipe closed
>         at java.io.PipedInputStream.receive(Unknown Source)
>         at java.io.PipedInputStream.receive(Unknown Source)
>         at java.io.PipedOutputStream.write(Unknown Source)
>         at org.mortbay.util.IO.copy(IO.java:155)
>         at org.mortbay.util.IO.copy(IO.java:93)
>         at org.mortbay.ftp.DataPort.handle(DataPort.java:289)
>         at org.mortbay.ftp.DataPort.run(DataPort.java:168)
>
> Can the FTP client be fixed so that it catches this and aborts the
> download or is there something that I should be doing to handle this?
 I
> have tried catching the exception and doing an abort() and that
doesn't
> seem to do the trick.
>
> Thanks
> Tony
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using
Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit
http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support 
>



-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit
http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: FTP Client Issue

Greg Wilkins-5

Tony

thanks a million for a test case....   without it I probably would have left
this issue slide until I was less busy or it was forgotten.

But a test case is worth a whole lot of guilt... So I had a look and
it was a simple fix.  The datastream was not being nulled by a forced
close. In CVS now.

cheers


Tony Thompson wrote:

> Here is a simple application that demonstrates the issue:
>
> import java.io.InputStream;
>
> import java.net.InetAddress;
>
> import org.mortbay.ftp.Ftp;
>
> public class FtpTest {
>     public static void main(String[] args)
>         throws Throwable {
>
>         Ftp ftp = new Ftp( InetAddress.getByName( args[0] ), args[1],
> args[2] );
>
>         System.out.println( ftp.list() );
>         InputStream in = ftp.startGet( args[3] );
>         in.read();
>         in.close();
>
> //        ftp.close();
> //        ftp.open( InetAddress.getByName( args[0] ) );
> //        ftp.authenticate( args[1], args[2] );
>
>         System.out.println( ftp.list() );
>
>         ftp.close();
>     }
> }
>
> If you attempt to close and reopen the connection (uncomment the three
> lines), it hangs the thread.
>
> Tony
>
>
>>>>[hidden email] 05/30/05 02:22AM >>>
>
>
> Tony,
>
> I just had a quick inspection of the code, and it does look to me like
> the DataPort should be terminated correctly after such an exception?
>
> How are you seeing this stack trace?  In a debug output or as
> a jvm thread report?
>
> Have your tried closing and reopening the Ftp instance?
>
> Could you perhaps run this in a debugger and trace the handling of
> this exception?
>
> cheers
>
>
>
> Tony Thompson wrote:
>
>>I am using the FTP client and I am starting a large file download
>>using:
>>
>>public synchronized InputStream startGet(String remoteName)
>>
>>If I close that InputStream before I read the entire thing (i.e.
>
> cancel
>
>>the download), I can't use that FTP connection for anything.  I get
>
> the
>
>>following exception (from Jetty 5.1 FTP client):
>>
>>java.io.IOException: Pipe closed
>>        at java.io.PipedInputStream.receive(Unknown Source)
>>        at java.io.PipedInputStream.receive(Unknown Source)
>>        at java.io.PipedOutputStream.write(Unknown Source)
>>        at org.mortbay.util.IO.copy(IO.java:155)
>>        at org.mortbay.util.IO.copy(IO.java:93)
>>        at org.mortbay.ftp.DataPort.handle(DataPort.java:289)
>>        at org.mortbay.ftp.DataPort.run(DataPort.java:168)
>>
>>Can the FTP client be fixed so that it catches this and aborts the
>>download or is there something that I should be doing to handle this?
>
>  I
>
>>have tried catching the exception and doing an abort() and that
>
> doesn't
>
>>seem to do the trick.
>>
>>Thanks
>>Tony
>>
>>
>>-------------------------------------------------------
>>This SF.Net email is sponsored by Yahoo.
>>Introducing Yahoo! Search Developer Network - Create apps using
>
> Yahoo!
>
>>Search APIs Find out how you can build Yahoo! directly into your own
>>Applications - visit
>
> http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 
>
>>_______________________________________________
>>Jetty-support mailing list
>>[hidden email]
>>https://lists.sourceforge.net/lists/listinfo/jetty-support 
>>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit
> http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support
>



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: FTP Client Issue

Tony Thompson
In reply to this post by Tony Thompson
Well, I have been testing the fix you provided and it did fix my example
app.  But, unfortunately, my example app didn't model my real world
scenario well enough.  So, I was able to change my example app a bit and
I am now running into this error:

Exception in thread "main" java.io.IOException: Pipe closed
        at java.io.PipedInputStream.receive(Unknown Source)
        at java.io.PipedInputStream.receive(Unknown Source)
        at java.io.PipedOutputStream.write(Unknown Source)
        at org.mortbay.util.IO.copy(IO.java:155)
        at org.mortbay.util.IO.copy(IO.java:93)
        at org.mortbay.ftp.DataPort.handle(DataPort.java:343)
        at org.mortbay.ftp.DataPort.run(DataPort.java:190)

Following is my modified test app.  In order for it to fail, the file
you are trying to download should be larger than 1K.

public class FtpTest {
    public static void main(String[] args)
        throws Throwable {

        Ftp ftp = new Ftp( InetAddress.getByName( args[0] ), args[1],
args[2] );

        System.out.println( ftp.list() );
        InputStream in = ftp.startGet( args[3] );
        byte[] buffer = new byte[1024*4];
        System.out.println( "Read: " +in.read( buffer ) );
        in.close();

//        ftp.close();
//        ftp.open( InetAddress.getByName( args[0] ) );
//        ftp.authenticate( args[1], args[2] );

        System.out.println( ftp.list() );

        ftp.close();
    }
}

>>> [hidden email] 05/30/05 02:22AM >>>

Tony,

I just had a quick inspection of the code, and it does look to me like
the DataPort should be terminated correctly after such an exception?

How are you seeing this stack trace?  In a debug output or as
a jvm thread report?

Have your tried closing and reopening the Ftp instance?

Could you perhaps run this in a debugger and trace the handling of
this exception?

cheers



Tony Thompson wrote:
> I am using the FTP client and I am starting a large file download
> using:
>
> public synchronized InputStream startGet(String remoteName)
>
> If I close that InputStream before I read the entire thing (i.e.
cancel
> the download), I can't use that FTP connection for anything.  I get
the

> following exception (from Jetty 5.1 FTP client):
>
> java.io.IOException: Pipe closed
>         at java.io.PipedInputStream.receive(Unknown Source)
>         at java.io.PipedInputStream.receive(Unknown Source)
>         at java.io.PipedOutputStream.write(Unknown Source)
>         at org.mortbay.util.IO.copy(IO.java:155)
>         at org.mortbay.util.IO.copy(IO.java:93)
>         at org.mortbay.ftp.DataPort.handle(DataPort.java:289)
>         at org.mortbay.ftp.DataPort.run(DataPort.java:168)
>
> Can the FTP client be fixed so that it catches this and aborts the
> download or is there something that I should be doing to handle this?
 I
> have tried catching the exception and doing an abort() and that
doesn't
> seem to do the trick.
>
> Thanks
> Tony
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using
Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit
http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support 
>



-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit
http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: FTP Client Issue

Greg Wilkins-5
Doh!

I'll look at this before the next release.... but that may be some time...
I'll see how I go...

cheers


Tony Thompson wrote:

> Well, I have been testing the fix you provided and it did fix my example
> app.  But, unfortunately, my example app didn't model my real world
> scenario well enough.  So, I was able to change my example app a bit and
> I am now running into this error:
>
> Exception in thread "main" java.io.IOException: Pipe closed
>         at java.io.PipedInputStream.receive(Unknown Source)
>         at java.io.PipedInputStream.receive(Unknown Source)
>         at java.io.PipedOutputStream.write(Unknown Source)
>         at org.mortbay.util.IO.copy(IO.java:155)
>         at org.mortbay.util.IO.copy(IO.java:93)
>         at org.mortbay.ftp.DataPort.handle(DataPort.java:343)
>         at org.mortbay.ftp.DataPort.run(DataPort.java:190)
>
> Following is my modified test app.  In order for it to fail, the file
> you are trying to download should be larger than 1K.
>
> public class FtpTest {
>     public static void main(String[] args)
>         throws Throwable {
>
>         Ftp ftp = new Ftp( InetAddress.getByName( args[0] ), args[1],
> args[2] );
>
>         System.out.println( ftp.list() );
>         InputStream in = ftp.startGet( args[3] );
>         byte[] buffer = new byte[1024*4];
>         System.out.println( "Read: " +in.read( buffer ) );
>         in.close();
>
> //        ftp.close();
> //        ftp.open( InetAddress.getByName( args[0] ) );
> //        ftp.authenticate( args[1], args[2] );
>
>         System.out.println( ftp.list() );
>
>         ftp.close();
>     }
> }
>
>
>>>>[hidden email] 05/30/05 02:22AM >>>
>
>
> Tony,
>
> I just had a quick inspection of the code, and it does look to me like
> the DataPort should be terminated correctly after such an exception?
>
> How are you seeing this stack trace?  In a debug output or as
> a jvm thread report?
>
> Have your tried closing and reopening the Ftp instance?
>
> Could you perhaps run this in a debugger and trace the handling of
> this exception?
>
> cheers
>
>
>
> Tony Thompson wrote:
>
>>I am using the FTP client and I am starting a large file download
>>using:
>>
>>public synchronized InputStream startGet(String remoteName)
>>
>>If I close that InputStream before I read the entire thing (i.e.
>
> cancel
>
>>the download), I can't use that FTP connection for anything.  I get
>
> the
>
>>following exception (from Jetty 5.1 FTP client):
>>
>>java.io.IOException: Pipe closed
>>        at java.io.PipedInputStream.receive(Unknown Source)
>>        at java.io.PipedInputStream.receive(Unknown Source)
>>        at java.io.PipedOutputStream.write(Unknown Source)
>>        at org.mortbay.util.IO.copy(IO.java:155)
>>        at org.mortbay.util.IO.copy(IO.java:93)
>>        at org.mortbay.ftp.DataPort.handle(DataPort.java:289)
>>        at org.mortbay.ftp.DataPort.run(DataPort.java:168)
>>
>>Can the FTP client be fixed so that it catches this and aborts the
>>download or is there something that I should be doing to handle this?
>
>  I
>
>>have tried catching the exception and doing an abort() and that
>
> doesn't
>
>>seem to do the trick.
>>
>>Thanks
>>Tony
>>
>>
>>-------------------------------------------------------
>>This SF.Net email is sponsored by Yahoo.
>>Introducing Yahoo! Search Developer Network - Create apps using
>
> Yahoo!
>
>>Search APIs Find out how you can build Yahoo! directly into your own
>>Applications - visit
>
> http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 
>
>>_______________________________________________
>>Jetty-support mailing list
>>[hidden email]
>>https://lists.sourceforge.net/lists/listinfo/jetty-support 
>>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit
> http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
> a projector? How fast can you ride your desk chair down the office luge track?
> If you want to score the big prize, get to know the little guy.  
> Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support
>



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support