Skip to content

LDAP connection not closed due to DefaultDirContextValidator #489

Closed
@antoine777

Description

@antoine777

DefaultDirContextValidator class doesn't close NamingEnumeration searchResults.

As a consequence, the LDAP connection associated with the DirContext can't be closed when requested by the pool.

It's conform to the documentation : https://docs.oracle.com/javase/tutorial/jndi/ldap/close.html
"If the Context instance is sharing a connection with other Context and unterminated NamingEnumeration instances, the connection will not be closed until close() has been invoked on all such Context and NamingEnumeration instances"

DefaultDirContextValidator should close the NamingEnumeration searchResults in a finally block :

NamingEnumeration<SearchResult> = null;
...
try {
	searchResults = dirContext.search(this.base, this.filter, this.searchControls);
	...
} finally {
	if (searchResults != null) {
		try {
			searchResults.close();
		} catch (Exception e) {
		}
	}
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions