You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tubemq.apache.org by "Guo Jiwei (Jira)" <ji...@apache.org> on 2020/05/10 04:43:00 UTC

[jira] [Created] (TUBEMQ-96) Fix typo & use IllegalArgumentException

Guo Jiwei created TUBEMQ-96:
-------------------------------

             Summary: Fix typo & use IllegalArgumentException
                 Key: TUBEMQ-96
                 URL: https://issues.apache.org/jira/browse/TUBEMQ-96
             Project: Apache TubeMQ
          Issue Type: Improvement
            Reporter: Guo Jiwei
            Assignee: Guo Jiwei


1. Fix typo
  validConsumerGroupParmeter -> validConsumerGroupParameter

2. Use IllegalArgumentException
  In ConsumerConfig#validConsumerGroupParameter
{code:java}
private void validConsumerGroupParameter(String consumerGroup) throws Exception {
        if (TStringUtils.isBlank(consumerGroup)) {
            throw new Exception("Illegal parameter: consumerGroup is Blank!");
        }
        String tmpConsumerGroup = String.valueOf(consumerGroup).trim();
        if (tmpConsumerGroup.length() > TBaseConstants.META_MAX_GROUPNAME_LENGTH) {
            throw new Exception(new StringBuilder(512)
                    .append("Illegal parameter: the max length of consumerGroup is ")
                    .append(TBaseConstants.META_MAX_GROUPNAME_LENGTH)
                    .append(" characters").toString());
        }
        if (!tmpConsumerGroup.matches(TBaseConstants.META_TMP_GROUP_VALUE)) {
            throw new Exception(new StringBuilder(512)
                    .append("Illegal parameter: the value of consumerGroup")
                    .append(" must begin with a letter, ")
                    .append("can only contain characters,numbers,hyphen,and underscores").toString());
        }
    }
{code}
will change to throw IllegalArgumentException
{code:java}
private void validConsumerGroupParameter(String consumerGroup) throws Exception {
        if (TStringUtils.isBlank(consumerGroup)) {
            throw new IllegalArgumentException("Illegal parameter: consumerGroup is Blank!");
        }
        String tmpConsumerGroup = String.valueOf(consumerGroup).trim();
        if (tmpConsumerGroup.length() > TBaseConstants.META_MAX_GROUPNAME_LENGTH) {
            throw new IllegalArgumentException(new StringBuilder(512)
                    .append("Illegal parameter: the max length of consumerGroup is ")
                    .append(TBaseConstants.META_MAX_GROUPNAME_LENGTH)
                    .append(" characters").toString());
        }
        if (!tmpConsumerGroup.matches(TBaseConstants.META_TMP_GROUP_VALUE)) {
            throw new IllegalArgumentException(new StringBuilder(512)
                    .append("Illegal parameter: the value of consumerGroup")
                    .append(" must begin with a letter, ")
                    .append("can only contain characters,numbers,hyphen,and underscores").toString());
        }
    }
{code}





--
This message was sent by Atlassian Jira
(v8.3.4#803005)