Ali TAKAVCI created POOL-431:
--------------------------------
Summary: invalidateObject() throws exception on pool replenishment
failure after commons-pool upgrade to 2.13.0
Key: POOL-431
URL: https://issues.apache.org/jira/browse/POOL-431
Project: Commons Pool
Issue Type: Bug
Affects Versions: 2.13.0
Reporter: Ali TAKAVCI
*Description*
A behavioral regression was introduced in {{commons-pool 2.13.0}} as part of
the fix for {*}POOL-424{*}, which ensures that {{invalidateObject()}} replaces
the destroyed instance by internally calling {{{}addObject(){}}}.
This change breaks consumers whose object factories are not always capable of
producing new pooled instances on demand — for example, factories backed by
external resources that may be temporarily unavailable.
*Root cause:* {{invalidateObject()}} now calls {{addObject()}} internally. When
the factory fails to produce a new instance, {{addObject()}} throws an
exception, which propagates out of {{invalidateObject()}} and breaks the
invalidation flow entirely.
----
*Steps to Reproduce*
# Implement a {{PooledObjectFactory}} backed by a resource that can be
temporarily unavailable
# Upgrade {{commons-pool}} from {{2.12.1}} to {{2.13.0}}
# Call {{invalidateObject()}} while the factory is unable to produce a new
instance
# Observe that {{invalidateObject()}} throws an exception instead of silently
invalidating the object
----
*Expected Behavior*
{{invalidateObject()}} should successfully destroy/invalidate the target object
regardless of whether the pool can be immediately replenished.
*Actual Behavior*
{{invalidateObject()}} throws an exception when {{addObject()}} fails
internally, breaking the invalidation flow.
----
*Workarounds Considered*
* Catching and swallowing the exception from {{addObject()}} — introduces
silent failure risk
* Finding an alternative path to destroy the object without triggering
replenishment — no clean solution identified
Neither workaround is acceptable for downstream users without trade-offs.
----
*Proposed Solution*
Make the {{addObject()}} call within {{invalidateObject()}} optional,
controlled by a configuration flag (e.g., {{{}replenishOnInvalidate{}}}), so
that pools backed by fallible factories are not adversely impacted.
----
*References*
* POOL-424
* Upstream commit:
[{{apache/commons-pool@32fd701}}|https://github.com/apache/commons-pool/commit/32fd701]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)