public synchronized void unsubscribe() {
        this.subscription = Collections.emptySet();
        this.groupSubscription = Collections.emptySet();
        this.assignment.clear();
        this.subscribedPattern = null;
        this.subscriptionType = SubscriptionType.NONE;
        this.assignmentId++;
    }
Check whether pattern subscription is in use.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/SubscriptionState.java