Skip to content

Commit 43e14d0

Browse files
author
Vladimir Kotal
committed
close inactive servers in prepareServers()
1 parent d7b6797 commit 43e14d0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

plugins/src/main/java/opengrok/auth/plugin/ldap/LdapFacade.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,24 @@ private void setWebHooks(WebHooks webHooks) {
197197
* Go through all servers in the pool and record the first working.
198198
*/
199199
void prepareServers() {
200+
LOGGER.log(Level.FINER, "checking servers for {0}", this);
200201
for (int i = 0; i < servers.size(); i++) {
201202
LdapServer server = servers.get(i);
202203
if (server.isWorking() && actualServer == -1) {
203204
actualServer = i;
204205
}
205206
}
207+
208+
// Close the connections to the inactive servers.
209+
LOGGER.log(Level.FINER, "closing unused servers");
210+
for (int i = 0; i < servers.size(); i++) {
211+
if (i != actualServer) {
212+
servers.get(i).close();
213+
}
214+
}
215+
216+
LOGGER.log(Level.FINER, "server check done, chosen {0} as the current server",
217+
servers.get(actualServer));
206218
}
207219

208220
/**

0 commit comments

Comments
 (0)