Skip to content

Commit

Permalink
For stateful connections (FTP) limit to a maximum of 5 connections lo…
Browse files Browse the repository at this point in the history
…wering to 1 on failures.
  • Loading branch information
dkocher committed Nov 18, 2024
1 parent 3a7bdf6 commit 658164d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class DefaultSessionPool implements SessionPool {
private static final int POOL_WARNING_THRESHOLD = 5;

private final FailureDiagnostics<BackgroundException> diagnostics
= new DefaultFailureDiagnostics();
= new DefaultFailureDiagnostics();

private final ConnectionService connect;
private final TranscriptListener transcript;
Expand Down Expand Up @@ -154,9 +154,9 @@ public Session<?> borrow(final BackgroundActionState callback) throws Background
final BackgroundException failure = (BackgroundException) cause;
log.warn("Failure {} obtaining connection for {}", failure, this);
if(diagnostics.determine(failure) == FailureDiagnostics.Type.network) {
final int max = Math.max(1, pool.getMaxIdle() - 1);
log.warn("Lower maximum idle pool size to {} connections.", max);
pool.setMaxIdle(max);
final int max = Math.max(1, pool.getMaxTotal() - 1);
log.warn("Lower maximum total pool size to {} connections.", max);
pool.setMaxTotal(max);
// Clear pool from idle connections
pool.clear();
}
Expand Down
3 changes: 2 additions & 1 deletion defaults/src/main/resources/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ smb.protocol.negotiate.enable=true
# Session pool
connection.pool.minidle=1
connection.pool.maxidle=5
connection.pool.maxtotal=2147483647
connection.pool.maxtotal=5

# Default login name
connection.login.name=
connection.login.anon.name=anonymous
Expand Down

0 comments on commit 658164d

Please sign in to comment.