private void subscribeInternal(Pattern pattern, Optional<ConsumerRebalanceListener> listener) {
        acquireAndEnsureOpen();
        try {
            maybeThrowInvalidGroupIdException();
            if (pattern == null || pattern.toString().isEmpty())
                throw new IllegalArgumentException("Topic pattern to subscribe to cannot be " + (pattern == null ?
                    "null" : "empty"));
            log.info("Subscribed to pattern: '{}'", pattern);
            subscriptions.subscribe(pattern, listener);
            metadata.requestUpdateForNewTopics();
            updatePatternSubscription(metadata.fetch());
        } finally {
            release();
        }
    }
Release the light lock protecting the consumer from multithreaded access.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java