public static String maybeTruncateReason(final String reason) {
        if (reason.length() > 255) {
            return reason.substring(0, 255);
        } else {
            return reason;
        }
    }
Ensures that the provided {@code reason} remains within a range of 255 chars.
@param reason This is the reason that is sent to the broker over the wire
              as a part of {@code JoinGroupRequest} or {@code LeaveGroupRequest} messages.
@return a provided reason as is or truncated reason if it exceeds the 255 chars threshold.
clients/src/main/java/org/apache/kafka/common/requests/JoinGroupRequest.java