code: public void flush(FlushMode mode)
     {
  
        // Destroy connections in the pool
        for (ConnectionListener cl : listeners)
        {
           switch (mode)
           {
              case ALL:
              {
                 if (Tracer.isEnabled())
                    Tracer.destroyConnectionListener(pool.getConfiguration().getId(), this, cl,
                                                     false, false, false, true, false,
                                                     false, false,
                                                     Tracer.isRecordCallstacks() ?
                                                     new Throwable("CALLSTACK") : null);
                       
                 destroyAndRemoveConnectionListener(cl, listeners);
                 break;
              }
  
              case INVALID:
              {
                 if (cl.changeState(FREE, VALIDATION))
                 {
                    validateConnectionListener(listeners, cl, FREE);
                 }
                 break;
              }
              case IDLE:
              {
                 if (cl.changeState(FREE, FLUSH))
                 {
                    if (Tracer.isEnabled())
                       Tracer.destroyConnectionListener(pool.getConfiguration().getId(), this, cl,
                                                        false, false, false, true, false,
                                                        false, false,
                                                        Tracer.isRecordCallstacks() ?
                                                        new Throwable("CALLSTACK") : null);
                       
                    destroyAndRemoveConnectionListener(cl, listeners);
                 }
                 break;
              }
              case GRACEFULLY:
              {
                 if (cl.changeState(FREE, FLUSH))
                 {
                    if (Tracer.isEnabled())
                       Tracer.destroyConnectionListener(pool.getConfiguration().getId(), this, cl,
                                                        false, false, false, true, false,
                                                        false, false,
                                                        Tracer.isRecordCallstacks() ?
                                                        new Throwable("CALLSTACK") : null);
                    
                    destroyAndRemoveConnectionListener(cl, listeners);
                 }
                 else if (cl.getState() == IN_USE || cl.getState() == TO_POOL || cl.getState() == VALIDATION)
                 {
                    cl.setState(DESTROY);
                 }
                 break;
              }
           }
        }
  
        // Trigger prefill
        prefill();
     }
docs: {@inheritDoc}