From 1228ee6fe841fa3dbfcbe1a0e4a5f50998687c1b Mon Sep 17 00:00:00 2001 From: Hemika Yasinda Kodikara Date: Wed, 12 Aug 2015 12:35:48 +0530 Subject: [PATCH] Modified client ID generation. --- .../org/apache/jmeter/protocol/mqtt/utilities/Utils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/jmeter/protocol/mqtt/utilities/Utils.java b/src/main/java/org/apache/jmeter/protocol/mqtt/utilities/Utils.java index 702031f..9d1af7c 100644 --- a/src/main/java/org/apache/jmeter/protocol/mqtt/utilities/Utils.java +++ b/src/main/java/org/apache/jmeter/protocol/mqtt/utilities/Utils.java @@ -17,15 +17,15 @@ public class Utils { /** - * Creates a UUID. + * Creates a UUID. The UUID is modified to avoid "ClientId longer than 23 characters" for MQTT. * * @return A UUID as a string. * @throws NoSuchAlgorithmException */ public static String UUIDGenerator() throws NoSuchAlgorithmException { - SecureRandom prng = SecureRandom.getInstance("SHA1PRNG"); - HashIDGenerator hashIDGenerator = new HashIDGenerator("jmeter-mqtt", 5); - return hashIDGenerator.encrypt(prng.nextLong()); + String clientId = System.currentTimeMillis() + "." + System.getProperty("user.name"); + clientId = clientId.substring(0, 23); + return clientId; } /**