Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-8382

Allow creating synchronized pool CommonsPoolTargetSource

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Trivial
    • Resolution: Unresolved
    • Affects Version/s: 3.0.5
    • Fix Version/s: Waiting for Triage
    • Component/s: Core:AOP
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Some object factories aren't thread-safe and thus do not allow calling org.apache.commons.pool.PoolableObjectFactory#makeObject from within multiple threads. Commons-pool library provides convenient PoolUtils#synchronizedPool method to synchronize such factories. I can take advantage of this method by simply extending org.springframework.aop.target.CommonsPoolTargetSource:

      public class SynchCommonsPoolTargetSource extends CommonsPoolTargetSource {
      
      	@Override
      	protected ObjectPool createObjectPool() {
      		return PoolUtils.synchronizedPool(super.createObjectPool());
      	}
      
      }

      However it would be nice if CommonsPoolTargetSource itself had an option to synchronize the pool if required. Implementation is pretty straightforward (in org.springframework.aop.target.CommonsPoolTargetSource#createObjectPool):

      return synchronizedPool? PoolUtils.synchronizedPool(gop) : gop;

      where synchronizedPool would be accessible as factory property (field+setter).

        Attachments

          Activity

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              nurkiewicz Tomasz Nurkiewicz
              Last updater:
              Chris Beams
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                7 years, 4 days ago