0 Replies Latest reply on Jun 5, 2009 7:44 AM by timfox

    SessionFactories being garbage collected

    timfox

      I've noticed a *lot* of this, especially in the client integration tests:

      protected void setUp() throws Exception
       {
       super.setUp();
      
      ...
      
       ClientSessionFactory sf = new ClientSessionFactoryImpl(new TransportConfiguration(InVMConnectorFactory.class.getName()));
      
      ..
      
       session = sf.createSession(false, true, true);
       session.createQueue(address, queue, false);
      
       }
      


      The sf variable is local to the method, so when the method completes it is liable to be garbage collected, but the session is still being used.

      This can cause all sorts of problems. You *cannot* let the sf be garbage collected until you're finished with the session.

      This kind of thing is just asking for problems.

      Now, I need to go and change about 200 tests... :(