[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - SessionFactories being garbage collected

timfox do-not-reply at jboss.com
Fri Jun 5 07:45:15 EDT 2009


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... :(

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4235642#4235642

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4235642



More information about the jboss-dev-forums mailing list