From 7b027df89e1cf107dee9305d5b753460dc5d9889 Mon Sep 17 00:00:00 2001 From: kvr Date: Fri, 17 Jul 2015 20:45:04 +0200 Subject: [PATCH] SPRNET-1582: SimplePool releases dead objects but does not create new ones --- src/Spring/Spring.Core/Pool/Support/SimplePool.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Spring/Spring.Core/Pool/Support/SimplePool.cs b/src/Spring/Spring.Core/Pool/Support/SimplePool.cs index 4e017a97..d65dc91a 100644 --- a/src/Spring/Spring.Core/Pool/Support/SimplePool.cs +++ b/src/Spring/Spring.Core/Pool/Support/SimplePool.cs @@ -41,6 +41,7 @@ namespace Spring.Pool.Support /// Doug Lea /// Federico Spinazzi /// Mark Pollack + /// Zbynek Vyskovsky, kvr@centrum.cz public class SimplePool : IObjectPool { private readonly IPoolableObjectFactory factory; @@ -60,19 +61,20 @@ namespace Spring.Pool.Support /// /// The factory used to instantiate and manage the lifecycle of pooled objects. /// - /// The initial size of the pool. + /// The maximum size of the pool. + /// The initial size of the pool. /// /// If the supplied is . /// /// /// If the supplied is less than or equal to zero. /// - public SimplePool(IPoolableObjectFactory factory, int size) + public SimplePool(IPoolableObjectFactory factory, int maxSize, int initialSize) { AssertUtils.ArgumentNotNull(factory, "factory"); - this.available = new Semaphore(size); + this.available = new Semaphore(maxSize); this.factory = factory; - InitItems(size); + InitItems(initialSize); } /// @@ -145,7 +147,9 @@ namespace Spring.Pool.Support } if (!closed) { - throw new PoolException("No more valid objects in pool."); + object o = factory.MakeObject(); + busy.Add(o); + return o; } else {