Skip to content

Commit

Permalink
Fix the issue that env special case handling is missing in some case
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodyiam committed Jun 6, 2023
1 parent a1bf9eb commit 971b412
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
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

0 comments on commit 971b412

Please sign in to comment.