Hi,
thanks for your reply.
On Fri, Jan 29, 2010 at 3:01 AM, Atsuhiko Yamanaka <y...@jcraft.com> wrote:
> Hi,
>
> +-From: Roland Schulz <rol...@utk.edu> ---
> |_Date: Thu, 28 Jan 2010 20:35:57 -0500 __
> |
> |I have one problem. When Thread.interrupt() is called
> |while there is a sftp connection running I get errors like:
> |Caused by: 4:
> ...
>
> Who interrupts the thread?
>
Eclipse has the function Display.syncExec. It allows a worker thread to
interrupt the main thread if a worker thread has some work which needs to be
run on the main thread. At least this is my understanding.
I'm completely new to eclipse development.
> Is it easy to reproduce that exception if I try Eclipse PTP plug-in?
>
Not very easy. I can reproduce it by creating a remote project and using
Alt-Tab to make eclipse go in the background and back in the foreground
rapidly. Doing this rapidly makes it happen every time.
Without doing the Alt-Tab it happens not at all or very infrequently.
Because it depends on the timing it also makes a different on how fast the
ssh connection to the remote host is.
I'm happy to write a small test case to show it. As far as I understand from
looking at the debugger and the code it should happen whenever ChannelSftp
is interrupted by another thread using interrrupt().
>
> ...
> |Is this this behavior intended?
>
> No, we had not expected such an interrupt, frankly to say.
>
> |My understanding is that a channel (like ChannelSFTP) should either:
> |1) Ignore InterruptedException, complete the IO operation and then
> setting
> |the thread's interrupt status.
> |2) Throw InterruptedIOException
> |3) Implement InterruptibleChannel as e.g. java.nio.channels.FileChannel
> |and gracefully close the channel and throw a ClosedByInterruptException
>
> |At the moment it seems to throw a SftpException without
> |a message indicating that it got interrupted.
>
> You will find the reason by SftpException#getCause() method.
>
OK. Would it be enough to close the channel and reopen another ChannelSftp
to get back into a well defined state?
>
> |IMHO, the best would be if one could choose when opening a channel
> |wither it should behave like 1 or like 3.
>
> If the implementation should be changed, I'll choose to disconnect
> the channel in such a case.
>
For our current problem it would be nice to be able to choose that
ChannelSftp does not let itself be interrupted. For some files read by
eclipse in the main thread there is no good reason to be interrupted by the
user. And it would not hurt at all to let the syncExec to wait until the
sftp operation has completed. Thus in this case it would be nicer
if ChannelSftp would ignore the InterruptedException until the file
operation is done as java.io does. Without that we need to write a pretty
large workaround. Described here:
http://dev.eclipse.org/mhonarc/lists/ptp-dev/msg03317.html
But for transferring large files it might be nice to be able to interrupt
the transfer. This is why I said it would be nice if one could select the
behavior.
>
> By the way, I had not recognized that Eclipse PTP has been using jsch.
>
PTP can use RSE or the internal RemoteTools for remote file access. So far
mainly RSE was used because RemoteTools wasn't reliable yet. We are
currently working on fixing this. RemoteTools is more light-weight and
better suited than RSE for PTP.
Roland
--
ORNL/UT Center for Molecular Biophysics cmb.ornl.gov
865-241-1537, ORNL PO BOX 2008 MS6309
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users