Uploaded image for project: 'Commons Pool'
  1. Commons Pool
  2. POOL-283

'Object has already been returned to this pool or is invalid' for collections

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: 2.4.1
    • Labels:
      None

      Description

      This test throws exception:

       GenericObjectPoolConfig config = new GenericObjectPoolConfig ();
              config.setMaxTotal ( 2 );
      
              GenericObjectPool<Set> setsPool = new GenericObjectPool<> ( new BasePooledObjectFactory<Set> ()
              {
                  @Override
                  public Set create () throws Exception
                  {
                      return new HashSet();
                  }
      
                  @Override
                  public PooledObject<Set> wrap ( Set o )
                  {
                      return new DefaultPooledObject<> ( o );
                  }
      
                  @Override
                  public void passivateObject ( PooledObject<Set> p ) throws Exception
                  {
                      p.getObject ().clear ();
                      super.passivateObject ( p );
                  }
              }, config );
      
              final Set set1 = setsPool.borrowObject ();
      
              final Set set2 = setsPool.borrowObject ();
      
      
              setsPool.returnObject ( set1 );
              setsPool.returnObject ( set2 ); // this throws java.lang.IllegalStateException: Object has already been retured to this pool or is invalid
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              yavalek Valentin Mayamsin
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: