beiwei30 closed pull request #2329: supplemental change for pull request 1973 URL: https://github.com/apache/incubator-dubbo/pull/2329
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/LICENSE b/LICENSE index 42e2705ba0..b85622380c 100644 --- a/LICENSE +++ b/LICENSE @@ -217,11 +217,15 @@ This product bundles and repackages the following code in Google Guava 16.0.1, w * com.google.common.util.concurrent.ListenableFuture * com.google.common.util.concurrent.ListenableFutureTask -For the package org.apache.dubbo.common.threadlocal: +For the package org.apache.dubbo.common.threadlocal and org.apache.dubbo.common.timer: This product contains a modified portion of 'Netty', an event-driven asynchronous network application framework also under a "Apache License 2.0" license, see https://github.com/netty/netty/blob/4.1/LICENSE.txt: * io.netty.util.concurrent.FastThreadLocal * io.netty.util.internal.InternalThreadLocalMap + * io.netty.util.Timer + * io.netty.util.TimerTask + * io.netty.util.Timeout + * io.netty.util.HashedWheelTimer diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java b/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java index db5c43fee9..a54cc70b9b 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java @@ -18,7 +18,7 @@ import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; -import org.apache.dubbo.common.utils.StringUtils; +import org.apache.dubbo.common.utils.ClassHelper; import java.util.Queue; import java.util.Set; @@ -408,7 +408,7 @@ public long pendingTimeouts() { } private static void reportTooManyInstances() { - String resourceType = StringUtils.simpleClassName(HashedWheelTimer.class); + String resourceType = ClassHelper.simpleClassName(HashedWheelTimer.class); logger.error("You are creating too many " + resourceType + " instances. " + resourceType + " is a shared resource that must be reused across the JVM," + "so that only a few instances are created."); @@ -650,7 +650,7 @@ public void expire() { public String toString() { final long currentTime = System.nanoTime(); long remaining = deadline - currentTime + timer.startTime; - String simpleClassName = StringUtils.simpleClassName(this.getClass()); + String simpleClassName = ClassHelper.simpleClassName(this.getClass()); StringBuilder buf = new StringBuilder(192) .append(simpleClassName) @@ -802,4 +802,4 @@ private HashedWheelTimeout pollTimeout() { private boolean isWindows() { return System.getProperty("os.name", "").toLowerCase(Locale.US).contains("win"); } -} \ No newline at end of file +} diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ClassHelper.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ClassHelper.java index 8ecb8f4045..e38752fcab 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ClassHelper.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ClassHelper.java @@ -45,6 +45,8 @@ */ private static final Map<Class<?>, Class<?>> primitiveWrapperTypeMap = new HashMap<Class<?>, Class<?>>(8); + private static final char PACKAGE_SEPARATOR_CHAR = '.'; + static { primitiveWrapperTypeMap.put(Boolean.class, boolean.class); primitiveWrapperTypeMap.put(Byte.class, byte.class); @@ -205,4 +207,16 @@ public static String toShortString(Object obj) { return obj.getClass().getSimpleName() + "@" + System.identityHashCode(obj); } -} \ No newline at end of file + + public static String simpleClassName(Class<?> clazz) { + if (clazz == null) { + throw new NullPointerException("clazz"); + } + String className = clazz.getName(); + final int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR); + if (lastDotIdx > -1) { + return className.substring(lastDotIdx + 1); + } + return className; + } +} diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java index f403f2f55c..ccc5a10ccc 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java @@ -47,8 +47,6 @@ private static final Pattern INT_PATTERN = Pattern.compile("^\\d+$"); private static final int PAD_LIMIT = 8192; - private static final char PACKAGE_SEPARATOR_CHAR = '.'; - private StringUtils() { } @@ -720,16 +718,4 @@ public static String toArgumentString(Object[] args) { } return buf.toString(); } - - public static String simpleClassName(Class<?> clazz) { - if (clazz == null) { - throw new NullPointerException("clazz"); - } - String className = clazz.getName(); - final int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR); - if (lastDotIdx > -1) { - return className.substring(lastDotIdx + 1); - } - return className; - } -} \ No newline at end of file +} ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
