You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2021/08/25 05:17:21 UTC

[GitHub] [incubator-eventmesh] ruanwenjun commented on a change in pull request #510: [ISSUE #505]remove all RandomStringUtils.

ruanwenjun commented on a change in pull request #510:
URL: https://github.com/apache/incubator-eventmesh/pull/510#discussion_r695399598



##########
File path: eventmesh-sdk-java/src/test/java/org/apache/eventmesh/client/http/demo/AsyncPublishInstance.java
##########
@@ -32,6 +32,9 @@
 
     public static Logger logger = LoggerFactory.getLogger(AsyncPublishInstance.class);
 
+    private final static RandomStringGenerator randomGenerator = new RandomStringGenerator.Builder()

Review comment:
       It seems RandomStringGenerator is thread safe, so we can just hold one instance in our application.
   Can we add a new utils or factory to Wrapper RandomStringGenerator.
   ```java
   public class InnerStringUtils {
   
   	/**
   	 *  generate random number string
   	 * @param length string length
   	 * @return
   	 */
   	public static String generateRandomNumber(int length) {
   		return RandomStringGeneratorHolder.instance.generate(length);
   	}
   
   	public static class RandomStringGeneratorHolder() {
   		private static RandomStringGenerator instance = new RandomStringGenerator.Builder()
   				.withinRange('0', '9').build();
   	}
   
   }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org