Directory Client API
  1. Directory Client API
  2. DIRAPI-52

Connection seems to remain opened, leading to 'Too many open files' on some servers

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.0.0-M4, 1.0.0-M5
    • Fix Version/s: 1.0.0-M6
    • Labels:
      None
    • Environment:
      various, see description

      Description

      Testcase:

      final LdapConnectionConfig lcc = new LdapConnectionConfig();
      lcc.setLdapHost("ad.example.com");
      lcc.setUseSsl(true);
      lcc.setLdapPort(LdapConnectionConfig.DEFAULT_LDAPS_PORT);
      lcc.setTrustManagers(new NoVerificationTrustManager());

      for (int i = 0; i < 100; i++) {
      System.out.println;
      final LdapNetworkConnection connection = new LdapNetworkConnection(lcc);
      connection.bind();
      final EntryCursor cursor = connection.search("ou=something,dc=example.com", "(&(cn=comeCommonName)(objectClass=person)(sn=)(givenName=))", SearchScope.SUBTREE, "cn");
      while (cursor.next())

      { cursor.get(); }

      connection.unBind();
      connection.close();
      Thread.sleep(1000);
      }

      Running this on some servers causes many open files and they are growing on each iteration:
      lsof -p <pid>:
      ...
      java 18719 gofer 37u 0000 0,7 0 13 anon_inode
      java 18719 gofer 38r FIFO 0,6 0t0 9155974 pipe
      java 18719 gofer 39w FIFO 0,6 0t0 9155974 pipe
      java 18719 gofer 40u 0000 0,7 0 13 anon_inode
      java 18719 gofer 41r FIFO 0,6 0t0 9155976 pipe
      java 18719 gofer 42w FIFO 0,6 0t0 9155976 pipe
      java 18719 gofer 43u 0000 0,7 0 13 anon_inode
      java 18719 gofer 44r FIFO 0,6 0t0 9155977 pipe
      java 18719 gofer 45w FIFO 0,6 0t0 9155977 pipe
      java 18719 gofer 46u 0000 0,7 0 13 anon_inode
      java 18719 gofer 47r FIFO 0,6 0t0 9155978 pipe
      java 18719 gofer 48w FIFO 0,6 0t0 9155978 pipe
      java 18719 gofer 49u 0000 0,7 0 13 anon_inode
      java 18719 gofer 50r FIFO 0,6 0t0 9155980 pipe
      java 18719 gofer 51w FIFO 0,6 0t0 9155980 pipe
      java 18719 gofer 52u 0000 0,7 0 13 anon_inode
      java 18719 gofer 53r FIFO 0,6 0t0 9155981 pipe
      java 18719 gofer 54w FIFO 0,6 0t0 9155981 pipe
      java 18719 gofer 55u 0000 0,7 0 13 anon_inode
      java 18719 gofer 56r FIFO 0,6 0t0 9155982 pipe
      java 18719 gofer 57w FIFO 0,6 0t0 9155982 pipe
      java 18719 gofer 58u 0000 0,7 0 13 anon_inode
      java 18719 gofer 59r FIFO 0,6 0t0 9155984 pipe
      java 18719 gofer 60w FIFO 0,6 0t0 9155984 pipe
      java 18719 gofer 61u 0000 0,7 0 13 anon_inode
      java 18719 gofer 62r FIFO 0,6 0t0 9155985 pipe
      java 18719 gofer 63w FIFO 0,6 0t0 9155985 pipe
      java 18719 gofer 64u 0000 0,7 0 13 anon_inode
      java 18719 gofer 65r FIFO 0,6 0t0 9155986 pipe
      java 18719 gofer 66w FIFO 0,6 0t0 9155986 pipe
      ... and many many more

      This happens on:
      Linux somedns1 2.6.26-2-xen-686 #1 SMP Thu Jan 27 05:44:37 UTC 2011 i686 GNU/Linux
      java version "1.6.0_26"
      Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
      Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

      Also on another platform, but there are slightly less open pipes and anon_inodes:

      Linux somedns2 2.6.26-2-686-bigmem #1 SMP Wed Nov 4 21:12:12 UTC 2009 i686 GNU/Linux
      java version "1.6.0_12"
      Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
      Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)

      On my local computer I see only couple of open pipes and anon_inodes and they don't grow:
      Linux bono 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
      java version "1.6.0_26"
      Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
      Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

      I've found slightly similar isse here: http://issues.opennms.org/browse/NMS-4631
      New file handlers are being opened by Apache Mina. I am not sure who is responsible for closing it. In my testcase the connection is properly closed.

        Activity

        Hide
        Emmanuel Lecharny added a comment -

        This is not an API issue, it's an issue on your own system.

        Modify its configuration to allow a higher number of files to be opened (ulimit parameter on linux)

        Show
        Emmanuel Lecharny added a comment - This is not an API issue, it's an issue on your own system. Modify its configuration to allow a higher number of files to be opened (ulimit parameter on linux)
        Hide
        Martin Zdila added a comment -

        Hi Emmanuel

        The issue is not the low value of allowed opened files. The problem is that opened pipes never closes. See my testcase. Do you see there any issue? Do you think that it should cause so many opened pipes and anon_inodes? It is not observed just on a single environment.

        If I had a program that would be opening file stream but never closing it, would you recommend me to increase ulimit too?

        Show
        Martin Zdila added a comment - Hi Emmanuel The issue is not the low value of allowed opened files. The problem is that opened pipes never closes. See my testcase. Do you see there any issue? Do you think that it should cause so many opened pipes and anon_inodes? It is not observed just on a single environment. If I had a program that would be opening file stream but never closing it, would you recommend me to increase ulimit too?
        Hide
        Martin Zdila added a comment -

        Even simpler testcase:

        public class LdapTestcase {
        public static void main(final String[] args) throws Exception {
        final LdapConnectionConfig lcc = new LdapConnectionConfig();
        lcc.setLdapHost("ad.example.com");
        lcc.setUseSsl(true);
        lcc.setLdapPort(LdapConnectionConfig.DEFAULT_LDAPS_PORT);
        lcc.setTrustManagers(new NoVerificationTrustManager());

        for (int i = 0; i < 1000; i++)

        { System.out.println(i); final LdapNetworkConnection connection = new LdapNetworkConnection(lcc); connection.bind(); connection.unBind(); connection.close(); }

        }
        }

        Exception:

        2011-07-27 14:52:36,162 ERROR SimpleIoProcessorPool - Failed to create a new instance of org.apache.mina.transport.socket.nio.NioProcessor:null
        java.lang.reflect.InvocationTargetException
        at sun.reflect.GeneratedConstructorAccessor4.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:180)
        at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:112)
        at org.apache.mina.core.polling.AbstractPollingIoConnector.<init>(AbstractPollingIoConnector.java:93)
        at org.apache.mina.transport.socket.nio.NioSocketConnector.<init>(NioSocketConnector.java:56)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.connect(LdapNetworkConnection.java:495)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.bindAsync(LdapNetworkConnection.java:1274)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:1131)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:907)
        at mway.UserDaoApacheDirectoryLdapApiImpl.<init>(UserDaoApacheDirectoryLdapApiImpl.java:32)
        at mway.UserDaoApacheDirectoryLdapApiImpl.main(UserDaoApacheDirectoryLdapApiImpl.java:18)
        Caused by: org.apache.mina.core.RuntimeIoException: Failed to open a selector.
        at org.apache.mina.transport.socket.nio.NioProcessor.<init>(NioProcessor.java:61)
        ... 13 more
        Caused by: java.io.IOException: Too many open files
        at sun.nio.ch.EPollArrayWrapper.epollCreate(Native Method)
        at sun.nio.ch.EPollArrayWrapper.<init>(EPollArrayWrapper.java:69)
        at sun.nio.ch.EPollSelectorImpl.<init>(EPollSelectorImpl.java:52)
        at sun.nio.ch.EPollSelectorProvider.openSelector(EPollSelectorProvider.java:18)
        at java.nio.channels.Selector.open(Selector.java:209)
        at org.apache.mina.transport.socket.nio.NioProcessor.<init>(NioProcessor.java:59)
        ... 13 more
        Exception in thread "main" org.apache.mina.core.RuntimeIoException: Failed to create a new instance of org.apache.mina.transport.socket.nio.NioProcessor:null
        at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:198)
        at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:112)
        at org.apache.mina.core.polling.AbstractPollingIoConnector.<init>(AbstractPollingIoConnector.java:93)
        at org.apache.mina.transport.socket.nio.NioSocketConnector.<init>(NioSocketConnector.java:56)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.connect(LdapNetworkConnection.java:495)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.bindAsync(LdapNetworkConnection.java:1274)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:1131)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:907)
        at mway.UserDaoApacheDirectoryLdapApiImpl.<init>(UserDaoApacheDirectoryLdapApiImpl.java:32)
        at mway.UserDaoApacheDirectoryLdapApiImpl.main(UserDaoApacheDirectoryLdapApiImpl.java:18)
        Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.GeneratedConstructorAccessor4.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:180)
        ... 9 more
        Caused by: org.apache.mina.core.RuntimeIoException: Failed to open a selector.
        at org.apache.mina.transport.socket.nio.NioProcessor.<init>(NioProcessor.java:61)
        ... 13 more
        Caused by: java.io.IOException: Too many open files
        at sun.nio.ch.EPollArrayWrapper.epollCreate(Native Method)
        at sun.nio.ch.EPollArrayWrapper.<init>(EPollArrayWrapper.java:69)
        at sun.nio.ch.EPollSelectorImpl.<init>(EPollSelectorImpl.java:52)
        at sun.nio.ch.EPollSelectorProvider.openSelector(EPollSelectorProvider.java:18)
        at java.nio.channels.Selector.open(Selector.java:209)
        at org.apache.mina.transport.socket.nio.NioProcessor.<init>(NioProcessor.java:59)
        ... 13 more

        Again, increasing ulimit is not a solution, as this is used in a server application.

        Show
        Martin Zdila added a comment - Even simpler testcase: public class LdapTestcase { public static void main(final String[] args) throws Exception { final LdapConnectionConfig lcc = new LdapConnectionConfig(); lcc.setLdapHost("ad.example.com"); lcc.setUseSsl(true); lcc.setLdapPort(LdapConnectionConfig.DEFAULT_LDAPS_PORT); lcc.setTrustManagers(new NoVerificationTrustManager()); for (int i = 0; i < 1000; i++) { System.out.println(i); final LdapNetworkConnection connection = new LdapNetworkConnection(lcc); connection.bind(); connection.unBind(); connection.close(); } } } Exception: 2011-07-27 14:52:36,162 ERROR SimpleIoProcessorPool - Failed to create a new instance of org.apache.mina.transport.socket.nio.NioProcessor:null java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedConstructorAccessor4.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:180) at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:112) at org.apache.mina.core.polling.AbstractPollingIoConnector.<init>(AbstractPollingIoConnector.java:93) at org.apache.mina.transport.socket.nio.NioSocketConnector.<init>(NioSocketConnector.java:56) at org.apache.directory.ldap.client.api.LdapNetworkConnection.connect(LdapNetworkConnection.java:495) at org.apache.directory.ldap.client.api.LdapNetworkConnection.bindAsync(LdapNetworkConnection.java:1274) at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:1131) at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:907) at mway.UserDaoApacheDirectoryLdapApiImpl.<init>(UserDaoApacheDirectoryLdapApiImpl.java:32) at mway.UserDaoApacheDirectoryLdapApiImpl.main(UserDaoApacheDirectoryLdapApiImpl.java:18) Caused by: org.apache.mina.core.RuntimeIoException: Failed to open a selector. at org.apache.mina.transport.socket.nio.NioProcessor.<init>(NioProcessor.java:61) ... 13 more Caused by: java.io.IOException: Too many open files at sun.nio.ch.EPollArrayWrapper.epollCreate(Native Method) at sun.nio.ch.EPollArrayWrapper.<init>(EPollArrayWrapper.java:69) at sun.nio.ch.EPollSelectorImpl.<init>(EPollSelectorImpl.java:52) at sun.nio.ch.EPollSelectorProvider.openSelector(EPollSelectorProvider.java:18) at java.nio.channels.Selector.open(Selector.java:209) at org.apache.mina.transport.socket.nio.NioProcessor.<init>(NioProcessor.java:59) ... 13 more Exception in thread "main" org.apache.mina.core.RuntimeIoException: Failed to create a new instance of org.apache.mina.transport.socket.nio.NioProcessor:null at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:198) at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:112) at org.apache.mina.core.polling.AbstractPollingIoConnector.<init>(AbstractPollingIoConnector.java:93) at org.apache.mina.transport.socket.nio.NioSocketConnector.<init>(NioSocketConnector.java:56) at org.apache.directory.ldap.client.api.LdapNetworkConnection.connect(LdapNetworkConnection.java:495) at org.apache.directory.ldap.client.api.LdapNetworkConnection.bindAsync(LdapNetworkConnection.java:1274) at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:1131) at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:907) at mway.UserDaoApacheDirectoryLdapApiImpl.<init>(UserDaoApacheDirectoryLdapApiImpl.java:32) at mway.UserDaoApacheDirectoryLdapApiImpl.main(UserDaoApacheDirectoryLdapApiImpl.java:18) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedConstructorAccessor4.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:180) ... 9 more Caused by: org.apache.mina.core.RuntimeIoException: Failed to open a selector. at org.apache.mina.transport.socket.nio.NioProcessor.<init>(NioProcessor.java:61) ... 13 more Caused by: java.io.IOException: Too many open files at sun.nio.ch.EPollArrayWrapper.epollCreate(Native Method) at sun.nio.ch.EPollArrayWrapper.<init>(EPollArrayWrapper.java:69) at sun.nio.ch.EPollSelectorImpl.<init>(EPollSelectorImpl.java:52) at sun.nio.ch.EPollSelectorProvider.openSelector(EPollSelectorProvider.java:18) at java.nio.channels.Selector.open(Selector.java:209) at org.apache.mina.transport.socket.nio.NioProcessor.<init>(NioProcessor.java:59) ... 13 more Again, increasing ulimit is not a solution, as this is used in a server application.
        Hide
        Emmanuel Lecharny added a comment -

        Hi Martin,

        yes, it seems a bit more complicated than the titlle made me think it was. (This is why picking a good tittle is important

        Ok, let's investigate this issue.

        Show
        Emmanuel Lecharny added a comment - Hi Martin, yes, it seems a bit more complicated than the titlle made me think it was. (This is why picking a good tittle is important Ok, let's investigate this issue.
        Hide
        Emmanuel Lecharny added a comment -

        Hmmm, bad, bad ,bad

        Same error on my mac :
        Exception in thread "main" org.apache.mina.core.RuntimeIoException: Failed to initialize.
        at org.apache.mina.core.polling.AbstractPollingIoConnector.<init>(AbstractPollingIoConnector.java:183)
        at org.apache.mina.core.polling.AbstractPollingIoConnector.<init>(AbstractPollingIoConnector.java:93)
        at org.apache.mina.transport.socket.nio.NioSocketConnector.<init>(NioSocketConnector.java:56)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.connect(LdapNetworkConnection.java:496)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.bindAsync(LdapNetworkConnection.java:1287)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:1144)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:922)
        at org.i2l.samples.LdapTestCase.main(LdapTestCase.java:20)
        Caused by: java.io.IOException: Too many open files in system
        at sun.nio.ch.KQueueArrayWrapper.init(Native Method)
        at sun.nio.ch.KQueueArrayWrapper.<init>(KQueueArrayWrapper.java:76)
        at sun.nio.ch.KQueueSelectorImpl.<init>(KQueueSelectorImpl.java:51)
        at sun.nio.ch.KQueueSelectorProvider.openSelector(KQueueSelectorProvider.java:20)
        at java.nio.channels.Selector.open(Selector.java:209)
        at org.apache.mina.transport.socket.nio.NioSocketConnector.init(NioSocketConnector.java:131)
        at org.apache.mina.core.polling.AbstractPollingIoConnector.<init>(AbstractPollingIoConnector.java:178)
        ... 7 more

        And I'm using an even simpler test :

        import org.apache.directory.ldap.client.api.LdapConnectionConfig;
        import org.apache.directory.ldap.client.api.LdapNetworkConnection;

        public class LdapTestCase
        {
        public static void main(final String[] args) throws Exception
        {
        LdapConnectionConfig lcc = new LdapConnectionConfig();
        lcc.setLdapHost( "localhost" );
        //lcc.setUseSsl( true );
        lcc.setLdapPort( 10389 );
        //lcc.setTrustManagers(new NoVerificationTrustManager());

        for (int i = 0; i < 1000; i++)

        { System.out.println(i); LdapNetworkConnection connection = new LdapNetworkConnection(lcc); connection.bind(); connection.unBind(); connection.close(); }

        }
        }

        (no SSL at all)

        Show
        Emmanuel Lecharny added a comment - Hmmm, bad, bad ,bad Same error on my mac : Exception in thread "main" org.apache.mina.core.RuntimeIoException: Failed to initialize. at org.apache.mina.core.polling.AbstractPollingIoConnector.<init>(AbstractPollingIoConnector.java:183) at org.apache.mina.core.polling.AbstractPollingIoConnector.<init>(AbstractPollingIoConnector.java:93) at org.apache.mina.transport.socket.nio.NioSocketConnector.<init>(NioSocketConnector.java:56) at org.apache.directory.ldap.client.api.LdapNetworkConnection.connect(LdapNetworkConnection.java:496) at org.apache.directory.ldap.client.api.LdapNetworkConnection.bindAsync(LdapNetworkConnection.java:1287) at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:1144) at org.apache.directory.ldap.client.api.LdapNetworkConnection.bind(LdapNetworkConnection.java:922) at org.i2l.samples.LdapTestCase.main(LdapTestCase.java:20) Caused by: java.io.IOException: Too many open files in system at sun.nio.ch.KQueueArrayWrapper.init(Native Method) at sun.nio.ch.KQueueArrayWrapper.<init>(KQueueArrayWrapper.java:76) at sun.nio.ch.KQueueSelectorImpl.<init>(KQueueSelectorImpl.java:51) at sun.nio.ch.KQueueSelectorProvider.openSelector(KQueueSelectorProvider.java:20) at java.nio.channels.Selector.open(Selector.java:209) at org.apache.mina.transport.socket.nio.NioSocketConnector.init(NioSocketConnector.java:131) at org.apache.mina.core.polling.AbstractPollingIoConnector.<init>(AbstractPollingIoConnector.java:178) ... 7 more And I'm using an even simpler test : import org.apache.directory.ldap.client.api.LdapConnectionConfig; import org.apache.directory.ldap.client.api.LdapNetworkConnection; public class LdapTestCase { public static void main(final String[] args) throws Exception { LdapConnectionConfig lcc = new LdapConnectionConfig(); lcc.setLdapHost( "localhost" ); //lcc.setUseSsl( true ); lcc.setLdapPort( 10389 ); //lcc.setTrustManagers(new NoVerificationTrustManager()); for (int i = 0; i < 1000; i++) { System.out.println(i); LdapNetworkConnection connection = new LdapNetworkConnection(lcc); connection.bind(); connection.unBind(); connection.close(); } } } (no SSL at all)
        Hide
        Emmanuel Lecharny added a comment -

        Changed the tittle

        Show
        Emmanuel Lecharny added a comment - Changed the tittle
        Hide
        Pierre-Arnaud Marcelot added a comment -

        After some debugging session with Emmanuel, we found out the following things:

        • A connector is initialized at first when the connection is bound.
        • Calling the unbind causes the server to close the session with the connection.
        • With the connection being closed, the sessionClose() method of the LdapNetworkConnection class is called
        • This method is not disposing the connector but setting it to null
        • Afterwards when the close() method is called on the LdapNetworkConnection, it can't dispose the connector as it has been nullified by the other method.
          => Thus, the connection is still open.

        Calling the connector.dispose() method in the sessionClosed() method seem to resolve the issue, but the following comment found in that method make us think that this change needs to be double checked:
        // DO NOT call connector.dispose(), it is hanging when there is no network connection

        We were able to increase to loop to 10,000 iterations with a successful ending.
        However, from time to time, we are hitting some NPEs, mainly due to concurrency (one method nullifying a field used in another method at the same time).

        We are currently trying to find the best way to schedule the connector.dispose() method call.

        Show
        Pierre-Arnaud Marcelot added a comment - After some debugging session with Emmanuel, we found out the following things: A connector is initialized at first when the connection is bound. Calling the unbind causes the server to close the session with the connection. With the connection being closed, the sessionClose() method of the LdapNetworkConnection class is called This method is not disposing the connector but setting it to null Afterwards when the close() method is called on the LdapNetworkConnection, it can't dispose the connector as it has been nullified by the other method. => Thus, the connection is still open. Calling the connector.dispose() method in the sessionClosed() method seem to resolve the issue, but the following comment found in that method make us think that this change needs to be double checked: // DO NOT call connector.dispose(), it is hanging when there is no network connection We were able to increase to loop to 10,000 iterations with a successful ending. However, from time to time, we are hitting some NPEs, mainly due to concurrency (one method nullifying a field used in another method at the same time). We are currently trying to find the best way to schedule the connector.dispose() method call.
        Hide
        Emmanuel Lecharny added a comment -

        I do think that the comment (// DO NOT...) was added when we were using an old version of MINA, whch might have some bug.

        anyway...

        I have fixed the NPE by protecting the connector.dispose() call with a mutex, removing the localConnector variable.

        Show
        Emmanuel Lecharny added a comment - I do think that the comment (// DO NOT...) was added when we were using an old version of MINA, whch might have some bug. anyway... I have fixed the NPE by protecting the connector.dispose() call with a mutex, removing the localConnector variable.
        Hide
        Emmanuel Lecharny added a comment -

        Ok, fix applied.

        http://svn.apache.org/viewvc?rev=1151527&view=rev

        Martin, many thanks for the bug report, for having persisted and reopened the issue and for having provided he code to reproduce the error.

        We will try to get a release by the end of this week.

        Show
        Emmanuel Lecharny added a comment - Ok, fix applied. http://svn.apache.org/viewvc?rev=1151527&view=rev Martin, many thanks for the bug report, for having persisted and reopened the issue and for having provided he code to reproduce the error. We will try to get a release by the end of this week.
        Hide
        Emmanuel Lecharny added a comment -

        Fix applied

        Show
        Emmanuel Lecharny added a comment - Fix applied
        Hide
        Martin Zdila added a comment -

        Thanks. I will check it later as we switched to JNDI as a fallback

        Show
        Martin Zdila added a comment - Thanks. I will check it later as we switched to JNDI as a fallback
        Hide
        Emmanuel Lecharny added a comment -

        A vote for a new release is currently being conducted. Expect a new release in 2 days.

        Show
        Emmanuel Lecharny added a comment - A vote for a new release is currently being conducted. Expect a new release in 2 days.

          People

          • Assignee:
            Unassigned
            Reporter:
            Martin Zdila
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development