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 Oct 31, 2024
1 parent 5796885 commit a882663
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 @@ -164,9 +164,9 @@ public Session<?> borrow(final BackgroundActionState callback) throws Background
final BackgroundException failure = (BackgroundException) cause;
log.warn(String.format("Failure %s obtaining connection for %s", failure, this));
if(diagnostics.determine(failure) == FailureDiagnostics.Type.network) {
final int max = Math.max(1, pool.getMaxIdle() - 1);
log.warn(String.format("Lower maximum idle pool size to %d connections.", max));
pool.setMaxIdle(max);
final int max = Math.max(1, pool.getMaxTotal() - 1);
log.warn(String.format("Lower maximum total pool size to %d 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 a882663

Please sign in to comment.