From 8217e8fbf404d1516584cadfe50a9513d159cd91 Mon Sep 17 00:00:00 2001 From: Ian Roberts Date: Sun, 17 Oct 2021 11:58:13 +0100 Subject: [PATCH] Permit a zero value for the scavenge interval configuration option. The JavaDoc says you can set a zero value to disable the scavenger, and the ObjectPool respects this, but setScavengeIntervalMilliseconds throws an exception if you try to actually set the interval to zero. Closes #38 --- src/main/java/cn/danielw/fop/PoolConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/cn/danielw/fop/PoolConfig.java b/src/main/java/cn/danielw/fop/PoolConfig.java index ead61ce..76ade7e 100755 --- a/src/main/java/cn/danielw/fop/PoolConfig.java +++ b/src/main/java/cn/danielw/fop/PoolConfig.java @@ -77,9 +77,9 @@ public int getScavengeIntervalMilliseconds() { * @return the pool config */ public PoolConfig setScavengeIntervalMilliseconds(int scavengeIntervalMilliseconds) { - if (scavengeIntervalMilliseconds < 5000) { + if (scavengeIntervalMilliseconds != 0 && scavengeIntervalMilliseconds < 5000) { throw new IllegalArgumentException("Cannot set interval too short (" + scavengeIntervalMilliseconds + - "), must be at least 5 seconds"); + "), must be at least 5 seconds, or zero to disable scavenger"); } this.scavengeIntervalMilliseconds = scavengeIntervalMilliseconds; return this;