public RecyclingSupplier<T> build() throws ObjectCreationException { final ScalableObjectPool<T> underlyingPool = new ScalableObjectPool<>(initialSize, maxSize, factory, fair); final RecyclingSupplier<T> pool; if (borrowHook != null || returnHook != null) { pool = new ObjectPoolWrapper<>(underlyingPool, borrowHook, returnHook); } else { pool = underlyingPool; } if (maintenanceExecutor != null) { maintenanceExecutor.scheduleWithFixedDelay(new MaintenanceRunner<>(underlyingPool, collectBorrowed), maintenanceIntervalMillis, maintenanceIntervalMillis, TimeUnit.MILLISECONDS); } return pool; }