Interrupted connect

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

Interrupted connect

Thomas Krammer
Hi everyone,

I found a bug in jcifs.util.transport.Transport. If the thread executing
Transport.connect() is interrupted all following connect() calls fail
with a TransportException "Invalid state: 1".

The reason for this is that the state isn't reset by the
InterruptedException handler.

The attached patch fixes this problem.


Bye,

   Thomas

--- jcifs\util\transport\Transport.java Fri Nov 18 16:21:24 2005
+++ ..\..\jcifs_1.2.6\src\jcifs\util\transport\Transport.java Wed Nov 23 13:13:33 2005
@@ -167,6 +167,8 @@
             try {
                 thread.wait( timeout );          /* wait for doConnect */
             } catch( InterruptedException ie ) {
+                state = 0;
+                thread = null;
                 throw new TransportException( ie );
             }
 
Reply | Threaded
Open this post in threaded view
|

Re: Interrupted connect

Michael B Allen-4
On Wed, 23 Nov 2005 14:39:52 +0100
Thomas Krammer <[hidden email]> wrote:

> Hi everyone,
>
> I found a bug in jcifs.util.transport.Transport. If the thread executing
> Transport.connect() is interrupted all following connect() calls fail
> with a TransportException "Invalid state: 1".
>
> The reason for this is that the state isn't reset by the
> InterruptedException handler.
>
> The attached patch fixes this problem.

Ok, I'll add this to The List.

Just out of curiousity, under what conditions would the transport thread
be interrupted?

Mike
Reply | Threaded
Open this post in threaded view
|

Re: Interrupted connect

Thomas Krammer


>>Hi everyone,
>>
>>I found a bug in jcifs.util.transport.Transport. If the thread executing
>>Transport.connect() is interrupted all following connect() calls fail
>>with a TransportException "Invalid state: 1".
>>
>>The reason for this is that the state isn't reset by the
>>InterruptedException handler.
>>
>>The attached patch fixes this problem.
>
>
> Ok, I'll add this to The List.
>
> Just out of curiousity, under what conditions would the transport thread
> be interrupted?
>

We created a JCifsFileSystemView that allows to browse the Windows
domain in a JFileChooser. The JFileChooser calls the FileSystemView in a
background thread. That thread is interrupted during the showDialog()
call of the JFileChooser. Depending on the timing this might interrupt
the connect() call since enumeration of the initial directory already
started.
Reply | Threaded
Open this post in threaded view
|

Re: Interrupted connect

Michael B Allen-4
On Thu, 24 Nov 2005 11:52:36 +0100
Thomas Krammer <[hidden email]> wrote:

>
>
> >>Hi everyone,
> >>
> >>I found a bug in jcifs.util.transport.Transport. If the thread executing
> >>Transport.connect() is interrupted all following connect() calls fail
> >>with a TransportException "Invalid state: 1".
> >>
> >>The reason for this is that the state isn't reset by the
> >>InterruptedException handler.
> >>
> >>The attached patch fixes this problem.
> >
> >
> > Ok, I'll add this to The List.
> >
> > Just out of curiousity, under what conditions would the transport thread
> > be interrupted?
> >
>
> We created a JCifsFileSystemView that allows to browse the Windows
> domain in a JFileChooser. The JFileChooser calls the FileSystemView in a
> background thread. That thread is interrupted during the showDialog()
> call of the JFileChooser. Depending on the timing this might interrupt
> the connect() call since enumeration of the initial directory already
> started.

Ok, but *why* do you interrupt the transport thread? You really shouldn't
do that. It's just not good programming style. It creates potentially
many more exit conditions. Anyway it's certainly not something supported
by the jcifs client.

Mike
Reply | Threaded
Open this post in threaded view
|

Re: Interrupted connect

Thomas Krammer
Michael B Allen wrote:

> On Thu, 24 Nov 2005 11:52:36 +0100
> Thomas Krammer <[hidden email]> wrote:
>
>
>>
>>>>Hi everyone,
>>>>
>>>>I found a bug in jcifs.util.transport.Transport. If the thread executing
>>>>Transport.connect() is interrupted all following connect() calls fail
>>>>with a TransportException "Invalid state: 1".
>>>>
>>>>The reason for this is that the state isn't reset by the
>>>>InterruptedException handler.
>>>>
>>>>The attached patch fixes this problem.
>>>
>>>
>>>Ok, I'll add this to The List.
>>>
>>>Just out of curiousity, under what conditions would the transport thread
>>>be interrupted?
>>>
>>
>>We created a JCifsFileSystemView that allows to browse the Windows
>>domain in a JFileChooser. The JFileChooser calls the FileSystemView in a
>>background thread. That thread is interrupted during the showDialog()
>>call of the JFileChooser. Depending on the timing this might interrupt
>>the connect() call since enumeration of the initial directory already
>>started.
>
>
> Ok, but *why* do you interrupt the transport thread? You really shouldn't
> do that. It's just not good programming style. It creates potentially
> many more exit conditions. Anyway it's certainly not something supported
> by the jcifs client.
>

I don't do it. Swing does it.