@Override
        public void run() {

            // Only run once
            if (!hasRun.compareAndSet(false, true))
                return;

            // Connection can no longer be shared
            activeConnection.invalidate();

            // Remove underlying tunnel from list of active tunnels
            UUID uuid = activeConnection.getUUID(); // May be null if record not successfully inserted
            if (uuid != null)
                activeTunnels.remove(uuid.toString());

            // Get original user
            RemoteAuthenticatedUser user = activeConnection.getUser();

            // Release the associated connection if this is the primary connection
            if (activeConnection.isPrimaryConnection()) {

                // Get connection and associated identifiers
                ModeledConnection connection = activeConnection.getConnection();
                String identifier = connection.getIdentifier();
                String parentIdentifier = connection.getParentIdentifier();

                // Release connection
                activeConnections.remove(identifier, activeConnection);
                activeConnectionGroups.remove(parentIdentifier, activeConnection);
                release(user, connection);

            }

            // Release any associated group
            if (activeConnection.hasBalancingGroup())
                release(user, activeConnection.getBalancingGroup());

            // Update history record with end date
            ConnectionRecordModel recordModel = activeConnection.getModel();
            recordModel.setEndDate(new Date());
            connectionRecordMapper.updateEndDate(recordModel);

        }
Creates a new task which automatically cleans up after the
connection associated with the given ActiveConnectionRecord. The
connection and parent group will be removed from the maps of active
connections and groups, and exclusive access will be released.

@param activeConnection
    The ActiveConnectionRecord whose associated connection should be
    cleaned up once this task runs.
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/AbstractGuacamoleTunnelService.java