Issue Details (XML | Word | Printable)

Key: DIRMINA-135
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Minor Minor
Assignee: Trustin Lee
Reporter: Julien Vermillard
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
MINA

exception during a connector.connect() aren't caught by filters

Created: 30/Nov/05 11:23 PM   Updated: 05/Dec/05 04:52 PM
Return to search
Component/s: None
Affects Version/s: 0.8.0, 0.8.1, 0.8.2
Fix Version/s: 0.9.0

Time Tracking:
Not Specified

Environment: MINA 0.8 and a SocketConnector

Resolution Date: 03/Dec/05 08:59 AM


 Description  « Hide
I try to do a reconnection filter, automaticly connecting and reconnecting a connector until it works.
if theinitial connector.connect(...) fail, and exception is thrown, but it's not caught by IoFilter chain. It's not really a bug I think but I added a simple fix :


in SocketConnector class in the connect method :
    public IoSession connect( SocketAddress address, SocketAddress localAddress,

                              int timeout, IoHandler handler ) throws IOException

I changed :

....
        if( request.exception != null )

        {

            ExceptionUtil.throwException( request.exception );

        }

....

into
....
        if( request.exception != null )
        {
        filters.exceptionCaught(null,request.exception );
            ExceptionUtil.throwException( request.exception );
        }
....

and now my filters get the exception normaly, perhaps it's an idea to add it to MINA 0.8 ?


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Niklas Therning added a comment - 30/Nov/05 11:50 PM
A reconnection filter would be great to have. But from what I understand you have a filter which tries to reconnect if the initial connect fails, right? Why not just do this in a while-loop instead?

while (!connected) {
  try {
    connector.connect();
    connected = true;
  } catch (ConnectException ce) {}
}

I think it would be more useful to have a filter which reconnects if an already established connection fails for some reason. And I think that's already possible in MINA 0.8 (if you can live with the blocking connect() call).

Another problem with this approach is that it won't work in MINA 0.9 and beyond. In MINA 0.9 there won't be a filter chain until a session has been created successfully so it won't be possible to call exceptionCaught() on the chain since there simply is no chain.

Julien Vermillard added a comment - 01/Dec/05 12:18 AM
It's how I do actualy I got a Thread for trying to connect the Connector, I tried to implement that in a filter and effectivly it's not really clever, I think my ReconnectionFilter will just try to reconnect disconnected connectors. This issue can be closed.

Trustin Lee added a comment - 01/Dec/05 12:28 AM
You can use a Callback in ConnectFuture instead. IoSession is not created if a connection is not established.

Julien Vermillard added a comment - 01/Dec/05 12:34 AM
ConnectFuture doesn't exist in 0.8 :)

Trustin Lee made changes - 03/Dec/05 08:59 AM
Field Original Value New Value
Assignee Trustin Lee [ trustin ]
Resolution Duplicate [ 3 ]
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 0.9 [ 11069 ]
Julien Vermillard made changes - 05/Dec/05 04:52 PM
Status Resolved [ 5 ] Closed [ 6 ]