dockerzhang / incubator-inlong

Apache InLong - a one-stop data streaming platform
https://inlong.apache.org/
Apache License 2.0
0 stars 0 forks source link

[INLONG-96] Fix typo & use IllegalArgumentException #96

Closed dockerzhang closed 3 years ago

dockerzhang commented 3 years ago

1. Fix typo
validConsumerGroupParmeter -> validConsumerGroupParameter
pushIsListenerWaitTimeoutRollBack -> pushListenerWaitTimeoutRollBack
pushIsListenerThrowedRollBack -> pushListenerThrowedRollBack

2. Use IllegalArgumentException
In ConsumerConfig#validConsumerGroupParameter

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());
}
    }

will change to throw IllegalArgumentException

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());
}
    }

JIRA link - [INLONG-96] created by technoboy