LdapNetworkConnection line 3400
public Entry lookup( Dn dn, Control[] controls, String... attributes )
throws LdapException
{
Entry entry = null;
try
{
SearchRequest searchRequest = new SearchRequestImpl();
searchRequest.setBase( dn );
searchRequest.setFilter( LdapConstants.OBJECT_CLASS_STAR );
searchRequest.setScope( SearchScope.OBJECT );
searchRequest.addAttributes( attributes );
searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );
if ( ( controls != null ) && ( controls.length > 0 ) )
{
searchRequest.addAllControls( controls );
}
Cursor<Response> cursor = search( searchRequest );
...
searchRequest timeLimit isn't being set, so it defaults to 0, which then sets
it to Long.MAX_VALUE in the getTimeout method
----- Original Message -----
From: "Emmanuel Lécharny" <[email protected]>
To: [email protected]
Sent: Wednesday, March 23, 2016 11:54:26 AM
Subject: Re: LDAP Connection Management
Le 22/03/16 21:27, Chris Pike a écrit :
> I've done lots of testing with redeploying while running jmeter tests, that's
> how I discovered the previous thread locking issues. I just haven't been able
> to reproduce this error in my local test environment.
>
> The thread dumps all show that the errors are on validating the connection
> while borrowing it from the pool. When I look through the ldap api...
>
> - The method lookup (line 3400 of LdapNetworkConnection) builds a search
> request with no timeout set (defaults to 0).
Actually, the default timeout is either 30s, or the timeout set for the
used connection. Not 0. If it's 0, that means it has been reset to 0
(which means infinite) :
LdapNetworkConnection, line 191
/** The timeout used for response we are waiting for */
private long timeout = LdapConnectionConfig.DEFAULT_TIMEOUT;
where LdapConnectionConfig.DEFAULT_TIMEOUT is 30s :
/** The default timeout for operation : 30 seconds */
public static final long DEFAULT_TIMEOUT = 30000L;
> - This eventually calls getTimeout on line 323, which returns Long.MAX_VALUE
> for the timeout, regardless of what the timeout on the connection config is
> set.
> else if ( searchTimeLimitInSeconds == 0 )
> {
> return Long.MAX_VALUE;
> }
Plain normal. As the connection timeout is 0, which means infinite, tis
is what we will use. The call is :
public SearchCursor search( SearchRequest searchRequest ) throws
LdapException
{
if ( searchRequest == null )
{
String msg = "Cannot process a null searchRequest";
LOG.debug( msg );
throw new IllegalArgumentException( msg );
}
SearchFuture searchFuture = searchAsync( searchRequest );
long searchTimeout = getTimeout( timeout,
searchRequest.getTimeLimit() );
Here, 'timeout' is the ldapConnection timeout (a global variable ).
> - Eventually this gets down into ResponseFuture line 130
> R response = queue.poll( timeout, unit );
>
> So even if I set the ldap connection timeout, I think it will be ignored
> because the SearchRequestImpl defaults to 0 and thus Long.MAX_VALUE
Again, the question is why is the connection having a timeout of 0 to
start with ?
Something should set it to 0 when creating the LcdapConnection, or
setting it to 0 later on. The best would be to set a breakpoint in the
setTimeout() method in LdapNetworkConnection, to see when it occurs.