diff --git a/apollo-common/pom.xml b/apollo-common/pom.xml
index 03c98adeb33..54f3a2ed48b 100644
--- a/apollo-common/pom.xml
+++ b/apollo-common/pom.xml
@@ -78,8 +78,8 @@
janino
- commons-lang
- commons-lang
+ org.apache.commons
+ commons-lang3
diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/UniqueKeyGenerator.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/UniqueKeyGenerator.java
index facbb2331f0..f914c7bb490 100644
--- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/UniqueKeyGenerator.java
+++ b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/UniqueKeyGenerator.java
@@ -16,12 +16,10 @@
*/
package com.ctrip.framework.apollo.common.utils;
-import com.google.common.base.Joiner;
-
import com.ctrip.framework.apollo.core.utils.ByteUtil;
import com.ctrip.framework.apollo.core.utils.MachineUtil;
-
-import org.apache.commons.lang.time.FastDateFormat;
+import com.google.common.base.Joiner;
+import org.apache.commons.lang3.time.FastDateFormat;
import java.security.SecureRandom;
import java.util.Date;
@@ -34,8 +32,6 @@ public class UniqueKeyGenerator {
private static final AtomicInteger counter = new AtomicInteger(new SecureRandom().nextInt());
private static final Joiner KEY_JOINER = Joiner.on("-");
-
-
public static String generate(Object... args){
String hexIdString =
ByteUtil.toHexString(toByteArray(Objects.hash(args), MachineUtil.getMachineIdentifier(),
diff --git a/apollo-core/pom.xml b/apollo-core/pom.xml
index 3292b1cf8a5..b0ed116bfd8 100644
--- a/apollo-core/pom.xml
+++ b/apollo-core/pom.xml
@@ -42,6 +42,10 @@
com.google.guava
guava
+
+ org.apache.commons
+ commons-lang3
+
diff --git a/apollo-core/src/main/java/com/ctrip/framework/foundation/internals/Utils.java b/apollo-core/src/main/java/com/ctrip/framework/foundation/internals/Utils.java
index 1eeaff3225e..ae080b1641e 100755
--- a/apollo-core/src/main/java/com/ctrip/framework/foundation/internals/Utils.java
+++ b/apollo-core/src/main/java/com/ctrip/framework/foundation/internals/Utils.java
@@ -16,18 +16,27 @@
*/
package com.ctrip.framework.foundation.internals;
-import com.google.common.base.Strings;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.SystemUtils;
public class Utils {
+
+ /**
+ * Judge if the given string contains any char.
+ *
+ * @param str
+ * @return true if the given string is blank
+ */
public static boolean isBlank(String str) {
- return Strings.nullToEmpty(str).trim().isEmpty();
+ return StringUtils.isBlank(str);
}
+ /**
+ * Judge if the system is windows.
+ *
+ * @return true if the current system is windows.
+ */
public static boolean isOSWindows() {
- String osName = System.getProperty("os.name");
- if (Utils.isBlank(osName)) {
- return false;
- }
- return osName.startsWith("Windows");
+ return SystemUtils.IS_OS_WINDOWS;
}
}
diff --git a/apollo-core/src/test/java/com/ctrip/framework/foundation/internals/UtilsTest.java b/apollo-core/src/test/java/com/ctrip/framework/foundation/internals/UtilsTest.java
index f3d63e3a4f2..769849ed0d6 100644
--- a/apollo-core/src/test/java/com/ctrip/framework/foundation/internals/UtilsTest.java
+++ b/apollo-core/src/test/java/com/ctrip/framework/foundation/internals/UtilsTest.java
@@ -25,11 +25,6 @@
public class UtilsTest {
private final String actualOsName = System.getProperty("os.name");
- @After
- public void tearDown() {
- System.setProperty("os.name", actualOsName);
- }
-
@Test
public void isBlankTrueGivenNull() {
assertTrue(Utils.isBlank(null));
@@ -57,32 +52,11 @@ public void isBlankFalseGivenWhitespacePadded() {
@Test
public void isOsWindowsTrueGivenWindows10() {
- System.setProperty("os.name", "Windows 10");
- assertTrue(Utils.isOSWindows());
+ if (actualOsName.startsWith("Windows")) {
+ assertTrue(Utils.isOSWindows());
+ } else {
+ assertFalse(Utils.isOSWindows());
+ }
}
- @Test
- public void isOSWindowsFalseGivenMacOsX() {
- System.setProperty("os.name", "Mac OS X");
- assertFalse(Utils.isOSWindows());
- }
-
- @Test
- public void isOSWindowsFalseGivenBlank() {
- System.setProperty("os.name", "");
- assertFalse(Utils.isOSWindows());
- }
-
- // Explicitly calling out case sensitivity; revisit if Microsoft changes naming convention
- @Test
- public void isOSWindowsFalseGivenAllUppercaseWindows() {
- System.setProperty("os.name", "WINDOWS 10");
- assertFalse(Utils.isOSWindows());
- }
-
- @Test
- public void isOSWindowsFalseGivenAllLowercaseWindows() {
- System.setProperty("os.name", "windows 10");
- assertFalse(Utils.isOSWindows());
- }
}
diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerService.java
index ed8fd9a3290..b09efbc5f0a 100644
--- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerService.java
+++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/service/ConsumerService.java
@@ -38,16 +38,16 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.hash.Hashing;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.stream.Collectors;
-import org.apache.commons.lang.time.FastDateFormat;
+import org.apache.commons.lang3.time.FastDateFormat;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
/**
* @author Jason Song(song_s@ctrip.com)
diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/ConfigPublishEmailBuilder.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/ConfigPublishEmailBuilder.java
index d90e17be709..ac54ab4b8d8 100644
--- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/ConfigPublishEmailBuilder.java
+++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/emailbuilder/ConfigPublishEmailBuilder.java
@@ -16,7 +16,6 @@
*/
package com.ctrip.framework.apollo.portal.component.emailbuilder;
-
import com.google.common.collect.Lists;
import com.ctrip.framework.apollo.common.constants.ReleaseOperation;
@@ -38,7 +37,7 @@
import com.ctrip.framework.apollo.portal.spi.UserService;
import com.ctrip.framework.apollo.portal.util.RoleUtils;
-import org.apache.commons.lang.time.FastDateFormat;
+import org.apache.commons.lang3.time.FastDateFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
@@ -50,7 +49,6 @@
import java.util.Set;
import java.util.regex.Matcher;
-
public abstract class ConfigPublishEmailBuilder {
private static final String EMERGENCY_PUBLISH_TAG = "(紧急发布)";
@@ -81,7 +79,6 @@ public abstract class ConfigPublishEmailBuilder {
protected FastDateFormat dateFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
-
@Autowired
private RolePermissionService rolePermissionService;
@Autowired
diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsExportController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsExportController.java
index da0f09092cd..2f497523ad9 100644
--- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsExportController.java
+++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsExportController.java
@@ -27,7 +27,7 @@
import com.ctrip.framework.apollo.portal.service.NamespaceService;
import com.ctrip.framework.apollo.portal.util.NamespaceBOUtils;
-import org.apache.commons.lang.time.DateFormatUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java
index a0d32fe1bf2..578bc705c9c 100644
--- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java
+++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ldap/LdapUserService.java
@@ -34,7 +34,7 @@
import java.util.TreeSet;
import javax.naming.directory.Attribute;
import javax.naming.ldap.LdapName;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.EmptyResultDataAccessException;
diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RelativeDateFormat.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RelativeDateFormat.java
index 8c67076c787..072915f969e 100644
--- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RelativeDateFormat.java
+++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/util/RelativeDateFormat.java
@@ -16,7 +16,7 @@
*/
package com.ctrip.framework.apollo.portal.util;
-import org.apache.commons.lang.time.FastDateFormat;
+import org.apache.commons.lang3.time.FastDateFormat;
import java.time.Duration;
import java.time.Instant;
@@ -24,7 +24,6 @@
import java.time.ZoneId;
import java.util.Date;
-
public class RelativeDateFormat {
private static final FastDateFormat TIMESTAMP_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd");
diff --git a/pom.xml b/pom.xml
index 89198a4e21b..b96bf01757a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,6 +70,7 @@
1.6.2
3.23.1-GA
1.4.0
+ 3.12.0
3.6.0
2.19.1
@@ -175,9 +176,9 @@
5.0.1
- commons-lang
- commons-lang
- 2.6
+ org.apache.commons
+ commons-lang3
+ ${common-lang3.version}