3 Replies Latest reply on Dec 2, 2009 5:21 PM by clebert.suconic

    NPE When creating sessions...

    clebert.suconic

      In the process of investigating the failures, I created a test that will start multiple threads while creating sessions..

      If I use the same ClientSessionFactory among all the threads, I will get this exception:

      java.lang.NullPointerException
       at org.hornetq.core.client.impl.ClientSessionFactoryImpl.createSessionInternal(ClientSessionFactoryImpl.java:1124)
       at org.hornetq.core.client.impl.ClientSessionFactoryImpl.createSession(ClientSessionFactoryImpl.java:884)
       at org.hornetq.tests.integration.cluster.reattach.ReattachTest$1CreateSessionThread.run(ReattachTest.java:480)





        • 1. Re: NPE When creating sessions...
          timfox

          The initialise needs to be sychronized

          • 2. Re: NPE When creating sessions...
            clebert.suconic

            As you know I'm debugging FailoverManager and MultiThreadReattach test... (just giving a little context for everybody else)


            I've made ClientSessionFactoryImpl::createSessionInternal synchronized as we talked, and now those tests are failing at the first iteration.


            Taking a thread dump right before the failure, I see that one thread is locking this:


            Thread-7" prio=10 tid=0x00007fa8d82c8800 nid=0x1cc1 waiting on condition [0x00007fa8d77f6000..0x00007fa8d77f6ce0]
             java.lang.Thread.State: TIMED_WAITING (parking)
             at sun.misc.Unsafe.park(Native Method)
             - parking to wait for <0x00007fa8e343bec8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
             at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)
             at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2054)
             at org.hornetq.core.remoting.impl.ChannelImpl.sendBlocking(ChannelImpl.java:238)
             - locked <0x00007fa8e343d008> (a java.lang.Object)
             at org.hornetq.core.client.impl.FailoverManagerImpl.createSession(FailoverManagerImpl.java:388)
             - locked <0x00007fa8e3451c18> (a java.lang.Object)
             at org.hornetq.core.client.impl.ClientSessionFactoryImpl.createSessionInternal(ClientSessionFactoryImpl.java:1124)
             - locked <0x00007fa90ea58958> (a org.hornetq.core.client.impl.ClientSessionFactoryImpl)
             - locked <0x00007fa90ea58958> (a org.hornetq.core.client.impl.ClientSessionFactoryImpl)
             at org.hornetq.core.client.impl.ClientSessionFactoryImpl.createSession(ClientSessionFactoryImpl.java:884)
             at org.hornetq.tests.integration.cluster.reattach.MultiThreadRandomReattachTestBase.createAutoCommitSession(MultiThreadRandomReattachTestBase.java:279)
             at org.hornetq.tests.integration.cluster.reattach.MultiThreadRandomReattachTestBase.doTestB(MultiThreadRandomReattachTestBase.java:435)
             at org.hornetq.tests.integration.cluster.reattach.MultiThreadRandomReattachTestBase$2.run(MultiThreadRandomReattachTestBase.java:95)
             at org.hornetq.tests.integration.cluster.reattach.MultiThreadReattachSupport$1Runner.run(MultiThreadReattachSupport.java:125)
            
            



            While another thread:


            "Timer-0" prio=10 tid=0x00007fa8d8238800 nid=0x1cb6 waiting for monitor entry [0x00007fa8dc48b000..0x00007fa8dc48bb60]
             java.lang.Thread.State: BLOCKED (on object monitor)
             at org.hornetq.core.client.impl.FailoverManagerImpl.removeSession(FailoverManagerImpl.java:500)
             - waiting to lock <0x00007fa8e3451c18> (a java.lang.Object)
             at org.hornetq.core.client.impl.ClientSessionImpl.doCleanup(ClientSessionImpl.java:1475)
             at org.hornetq.core.client.impl.ClientSessionImpl.cleanUp(ClientSessionImpl.java:764)
             - locked <0x00007fa90d1c4ba8> (a org.hornetq.core.client.impl.ClientSessionImpl)
             at org.hornetq.core.client.impl.FailoverManagerImpl.failoverOrReconnect(FailoverManagerImpl.java:730)
             at org.hornetq.core.client.impl.FailoverManagerImpl.handleConnectionFailure(FailoverManagerImpl.java:555)
             at org.hornetq.core.client.impl.FailoverManagerImpl.access$2(FailoverManagerImpl.java:553)
             at org.hornetq.core.client.impl.FailoverManagerImpl$DelegatingFailureListener.connectionFailed(FailoverManagerImpl.java:1131)
             at org.hornetq.core.remoting.impl.RemotingConnectionImpl.callFailureListeners(RemotingConnectionImpl.java:412)
             at org.hornetq.core.remoting.impl.RemotingConnectionImpl.fail(RemotingConnectionImpl.java:248)
             at org.hornetq.tests.integration.cluster.reattach.MultiThreadReattachSupport$Failer.run(MultiThreadReattachSupport.java:260)
             - locked <0x00007fa90ea58748> (a org.hornetq.tests.integration.cluster.reattach.MultiThreadReattachSupport$Failer)
             at java.util.TimerThread.mainLoop(Timer.java:512)
             at java.util.TimerThread.run(Timer.java:462)
            



            this last thread won't be able to finish failover and exit the loop.

            • 3. Re: NPE When creating sessions...
              clebert.suconic

              Never Mind: I had an invalid change on the test