Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue that env special case handling is missing in some case #4887

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Apollo 2.2.0
* [feat: check port use by another process or not when startup](https://github.com/apolloconfig/apollo/pull/4656)
* [Bump springboot version from 2.7.9 to 2.7.11](https://github.com/apolloconfig/apollo/pull/4828)
* [[Multi-Database Support][h2] Support run on h2](https://github.com/apolloconfig/apollo/pull/4851)
* [Fix the issue that env special case handling is missing in some case](https://github.com/apolloconfig/apollo/pull/4887)

------------------
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/13?closed=1)
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public class Env {
com.ctrip.framework.apollo.core.enums.Env.LOCAL.name());
public static final Env DEV = addEnvironment(
com.ctrip.framework.apollo.core.enums.Env.DEV.name());
public static final Env FWS = addEnvironment(
com.ctrip.framework.apollo.core.enums.Env.FWS.name());
public static final Env FAT = addEnvironment(
com.ctrip.framework.apollo.core.enums.Env.FAT.name());
public static final Env FWS = addEnvironment(
com.ctrip.framework.apollo.core.enums.Env.FWS.name());
public static final Env UAT = addEnvironment(
com.ctrip.framework.apollo.core.enums.Env.UAT.name());
public static final Env LPT = addEnvironment(
Expand Down Expand Up @@ -77,7 +77,20 @@ private static String getWellFormName(String envName) {
if (StringUtils.isBlank(envName)) {
return "";
}
return envName.trim().toUpperCase();

String envWellFormName = envName.trim().toUpperCase();

// special case for production in case of typo
if ("PROD".equals(envWellFormName)) {
return Env.PRO.name;
}

// special case that FAT & FWS should map to FAT
if ("FWS".equals(envWellFormName)) {
return Env.FAT.name;
}

return envWellFormName;
}

/**
Expand All @@ -88,15 +101,6 @@ private static String getWellFormName(String envName) {
*/
public static Env transformEnv(String envName) {
final String envWellFormName = getWellFormName(envName);
// special case for production in case of typo
if ("PROD".equalsIgnoreCase(envWellFormName)) {
return Env.PRO;
}

// special case that FAT & FWS should map to FAT
if ("FWS".equalsIgnoreCase(envWellFormName)) {
return Env.FAT;
}

if (Env.exists(envWellFormName)) {
return Env.valueOf(envWellFormName);
Expand Down