You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2019/07/21 23:25:00 UTC

[jira] [Work logged] (POOL-361) setTestOnCreate does not test on create

     [ https://issues.apache.org/jira/browse/POOL-361?focusedWorklogId=280187&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-280187 ]

ASF GitHub Bot logged work on POOL-361:
---------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Jul/19 23:24
            Start Date: 21/Jul/19 23:24
    Worklog Time Spent: 10m 
      Work Description: psteitz commented on pull request #23: Move validation for newly created objects into create(). Fixes POOL-361.
URL: https://github.com/apache/commons-pool/pull/23
 
 
   See comments in POOL-361
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 280187)
            Time Spent: 10m
    Remaining Estimate: 0h

> setTestOnCreate does not test on create
> ---------------------------------------
>
>                 Key: POOL-361
>                 URL: https://issues.apache.org/jira/browse/POOL-361
>             Project: Commons Pool
>          Issue Type: Bug
>    Affects Versions: 2.6.1
>            Reporter: Pablo
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> When setting testOnCreate to true, I would expect for the validation to take place when an object is created, but apparently it does not.
> It only seems to be tested on borrow and when idle.
> This has a negative impact, because when new objects get created, since they are not tested they appear in the pool as idle.
> I'm trying to determine if the pool's health, but even though the pool reports idle objects they are botched instances.
> Also related to this issue, objects aren't actually created upfront. They seem to be created on first borrow or when timeBetweenEvictionRunMillis elapses.
> Environment (unimportant I think): 1.8.0_191, Ubuntu 18.04
> Test case:
>  
> {code:java}
>  public static void main(String[] args) throws Exception {
>         PooledObjectFactory<String> factory = new BasePooledObjectFactory<String>() {
>             public String create() throws Exception {
>                 String s = "Hello";
>                 System.out.println("Creating " + s);
>                 return s;
>             }
>             public void destroyObject(PooledObject<String> p) throws Exception {
>                 System.out.println("Destroying " + p.getObject());
>             }
>             public boolean validateObject(PooledObject<String> p) {
>                 System.out.println("Validating " + p.getObject());
>                 return super.validateObject(p);
>             }
>             public PooledObject<String> wrap(String obj) {
>                 return new Wrapper<String>(obj);
>             }
>         };
>         GenericObjectPoolConfig<String> socketPoolConfig = new GenericObjectPoolConfig<String>();
>         socketPoolConfig.setTestOnCreate(true);
>         socketPoolConfig.setTestWhileIdle(false);
>         GenericObjectPool<String> objectPool = new GenericObjectPool<String>(factory, socketPoolConfig);
>         System.out.println("Pool created");
>         String f1 = objectPool.borrowObject();
>         System.out.println("Borrowed" + f1);
>         objectPool.returnObject(f1);
>         objectPool.close();
>         System.out.println("Done");
>     }{code}
>  
>  
> Expected result:
> {{        Pool created}}
> {{        Creating Hello}}
> {{        *Validating Hello*}}
> {{        Allocating Hello}}
> {{        BorrowedHello}}
> {{        DeallocatingHello}}
> {{        Destroying Hello}}
> {{        Done}}
>  
> Actual result:
> {{        Pool created}}
> {{        Creating Hello}}
> {{        Allocating Hello}}
> {{        *Validating Hello*}}
> {{        BorrowedHello}}
> {{        DeallocatingHello}}
> {{        Destroying Hello}}
> {{        Done}}
>  
>  Or am I misunderstanding something?
>  
>  
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)