Skip to content

Commit 47f29a3

Browse files
committed
8277795: ldap connection timeout not honoured under contention
Backport-of: 3d926dd66ef6551e91a4ebbbc59dcff58f5ede5a
1 parent 51e7af2 commit 47f29a3

File tree

5 files changed

+395
-143
lines changed

5 files changed

+395
-143
lines changed

src/java.naming/share/classes/com/sun/jndi/ldap/LdapClientFactory.java

+16
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,23 @@ public PooledConnection createPooledConnection(PoolCallback pcb)
6565
connTimeout, readTimeout, trace, pcb);
6666
}
6767

68+
public PooledConnection createPooledConnection(PoolCallback pcb, long timeout)
69+
throws NamingException {
70+
return new LdapClient(host, port, socketFactory,
71+
guardedIntegerCast(timeout),
72+
readTimeout, trace, pcb);
73+
}
74+
6875
public String toString() {
6976
return host + ":" + port;
7077
}
78+
79+
private int guardedIntegerCast(long timeout) {
80+
if (timeout < Integer.MIN_VALUE) {
81+
return Integer.MIN_VALUE;
82+
} else if (timeout > Integer.MAX_VALUE) {
83+
return Integer.MAX_VALUE;
84+
}
85+
return (int) timeout;
86+
}
7187
}

0 commit comments

Comments
 (0)