Skip to content

Commit

Permalink
optimize: optimize get config type from configuration (apache#2730)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeineLiang authored May 26, 2020
1 parent 7e04d2a commit 53963d4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ public static ConfigType getType(String name) {
return configType;
}
}
throw new IllegalArgumentException("illegal type:" + name);
throw new IllegalArgumentException("not support config type: " + name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.seata.common.exception.NotSupportYetException;
import io.seata.common.loader.EnhancedServiceLoader;
import io.seata.common.loader.EnhancedServiceNotFoundException;
import io.seata.common.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -101,9 +102,14 @@ private static Configuration buildConfiguration() {
configTypeName = CURRENT_FILE_INSTANCE.getConfig(
ConfigurationKeys.FILE_ROOT_CONFIG + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR
+ ConfigurationKeys.FILE_ROOT_TYPE);

if (StringUtils.isBlank(configTypeName)) {
throw new NotSupportYetException("config type can not be null");
}

configType = ConfigType.getType(configTypeName);
} catch (Exception e) {
throw new NotSupportYetException("not support register type: " + configTypeName, e);
throw e;
}
if (ConfigType.File == configType) {
String pathDataId = String.join(ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR, ConfigurationKeys.FILE_ROOT_CONFIG, FILE_TYPE, NAME_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package io.seata.discovery.registry;

import io.seata.common.exception.NotSupportYetException;

/**
* The enum Registry type.
*
Expand Down Expand Up @@ -72,6 +70,6 @@ public static RegistryType getType(String name) {
return registryType;
}
}
throw new NotSupportYetException("unsupported type:" + name);
throw new IllegalArgumentException("not support registry type: " + name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package io.seata.metrics.exporter;

import io.seata.common.exception.NotSupportYetException;

/**
* Supported metrics exporter type
*
Expand All @@ -42,7 +40,7 @@ public static ExporterType getType(String name) {
if (PROMETHEUS.name().equalsIgnoreCase(name)) {
return PROMETHEUS;
} else {
throw new NotSupportYetException("unsupported type:" + name);
throw new IllegalArgumentException("not support exporter type: " + name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package io.seata.metrics.registry;

import io.seata.common.exception.NotSupportYetException;

/**
* Supported metrics registry type
*
Expand All @@ -42,7 +40,7 @@ public static RegistryType getType(String name) {
if (COMPACT.name().equalsIgnoreCase(name)) {
return COMPACT;
} else {
throw new NotSupportYetException("unsupported type:" + name);
throw new IllegalArgumentException("not support registry type: " + name);
}
}
}

0 comments on commit 53963d4

Please sign in to comment.