ari-ban / glassfish-genericjmsra

0 stars 0 forks source link

InitialContext.close() is not called after use, leading to connection leak when LDAP used #48

Closed arinban closed 13 years ago

arinban commented 13 years ago

(Logged on behalf of an Oracle engineer)

When GenericJMSRA is initialized by GlassFish it is passed a class to act as a JNDI naming context factory, which it then uses to look up the connections it will make. Like many Java applications, GenericJMSRA makes the assumption that it can call 'new InitialContext (property_referencing_this_class)' as often as it likes with no consequences. It never calls 'close()' on the context returned.

This would be a safe thing to do in 99% of cases, but my customer uses LdapCtxFactory as the naming factory, so they can store configuration in an LDAP directory. But LdapCtxFactory creates a real, physical connection to the directory everytime someone does 'new InitialContext()' on it. It's one of the few JNDI factories I've seen that really does require the context be closed after use.

Anyway, because GRA never closes the context, the LDAP implementation never closes its connection, and over a period of a few weeks my customer is getting thousands of open connections to the directory, and then everything falls over.

arinban commented 6 years ago
arinban commented 13 years ago

@glassfishrobot Commented Reported by nigeldeakin

arinban commented 13 years ago

@glassfishrobot Commented nigeldeakin said: It should be possible to change com.sun.genericra.util.ObjectBuilderFactory.createObject to call InitialContext.close() before letting the InitialContext go out of scope. If this is implemented correctly when using LdapCtxFactory this should solve the problem.

arinban commented 13 years ago

@glassfishrobot Commented Was assigned to nigeldeakin

arinban commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GENERICJMSRA-48

arinban commented 13 years ago

@glassfishrobot Commented Marked as fixed on Thursday, February 10th 2011, 6:43:56 pm