public PlcConnection getConnection(String url) throws PlcConnectionException {
        // If the connection manager is already closed, abort.
        if(closed.get()) {
            throw new PlcConnectionManagerClosedException();
        }

        // Get a connection container for the given url.
        ConnectionContainer connectionContainer;
        synchronized (connectionContainers) {
            connectionContainer = connectionContainers.get(url);
            if (connectionContainer == null) {
                LOG.debug("Creating new connection");

                // Crate a connection container to manage handling this connection
                connectionContainer = new ConnectionContainer(connectionManager, url, maxLeaseTime, maxIdleTime,
                    closeConnection -> {
                        removeCachedConnection(closeConnection);
                        return null;
                    });
                connectionContainers.put(url, connectionContainer);
            } else {
                LOG.debug("Reusing exising connection");
            }
        }

        // Get a lease (a future for a connection)
        Future<PlcConnection> leaseFuture = connectionContainer.lease();
        try {
            return leaseFuture.get(this.maxWaitTime.toMillis(), TimeUnit.MILLISECONDS);
        } catch (ExecutionException | InterruptedException | TimeoutException e) {
            throw new PlcConnectionException("Error acquiring lease for connection", e);
        }
    }
Removes a given connection from the cache (Should only be used in order to remove somehow broken connections).
@param url url of the connection that should be removed.
plc4j/tools/connection-cache/src/main/java/org/apache/plc4x/java/utils/cache/CachedPlcConnectionManager.java