You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Edouard De Oliveira (JIRA)" <ji...@apache.org> on 2008/11/18 00:39:44 UTC

[jira] Commented: (DIRMINA-638) DefaultSocketSessionConfig creates some connection to itself.

    [ https://issues.apache.org/jira/browse/DIRMINA-638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12648414#action_12648414 ] 

Edouard De Oliveira commented on DIRMINA-638:
---------------------------------------------

I would bet that this issue is related with https://issues.apache.org/jira/browse/DIRMINA-628 (quote = " Windows Firewall dialog complaining about our software trying to perform an operation that needs to be blocked / unblocked before continuing").

I remind an old thread discussion saying that it was the reliable way to test if some socket opts where available but it is ?

> DefaultSocketSessionConfig creates some connection to itself.
> -------------------------------------------------------------
>
>                 Key: DIRMINA-638
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-638
>             Project: MINA
>          Issue Type: Bug
>    Affects Versions: 1.1.7, 2.0.0-M3
>            Reporter: Emmanuel Lecharny
>            Priority: Blocker
>             Fix For: 2.0.0-M4, 1.1.8
>
>
> For some unknown reason, the DefaultSocketSessionConfig class is creating a ServerSocket, and create a connection  :
>     static {
>         initializeTestAddresses();
>         boolean success = false;
>         for (Entry<InetSocketAddress, InetAddress> e : TEST_ADDRESSES.entrySet()) {
>             success = initializeDefaultSocketParameters(e.getKey(), e.getValue());
>             if (success) {
>                 break;
>             }
>         }
>     private static void initializeTestAddresses() {
>         try {
>             TEST_ADDRESSES.put(new InetSocketAddress(0), InetAddress.getByAddress(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 1 }));
>             TEST_ADDRESSES.put(new InetSocketAddress(0), InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
>         } catch (UnknownHostException e) {
>             ExceptionMonitor.getInstance().exceptionCaught(e);
>         }
>     }
>     private static boolean initializeDefaultSocketParameters(InetSocketAddress bindAddress, InetAddress connectAddress) {
>         ServerSocket ss = null;
>         Socket socket = null;
>         try {
>             ss = new ServerSocket();
>             ss.bind(bindAddress);
>             socket = new Socket();
>             socket.connect(new InetSocketAddress(connectAddress, ss.getLocalPort()), 10000);
>             initializeDefaultSocketParameters(socket);
>             return true;
>         } catch (IOException ioe) {
>             return false;
>         } finally {
>             if (socket != null) {
>                 try {
>                     socket.close();
>                 } catch (IOException e) {
>                     ExceptionMonitor.getInstance().exceptionCaught(e);
>                 }
>             }
>             if (ss != null) {
>                 try {
>                     ss.close();
>                 } catch (IOException e) {
>                     ExceptionMonitor.getInstance().exceptionCaught(e);
>                 }
>             }
>        }
>     }
> The _only_ reason why this code exists is to setup the default values for the socket configuration. 
> Not only is this bad code, but also a totally wrong thing to do : in many environment, creating sockets this way will lead to breakages (Applet, etc).
> It as to be fixed urgently.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.