Commit 183eeb05 authored by zengtianlai3's avatar zengtianlai3

Merge branch 'm33' into 'master'

解决null引用

See merge request !42
parents 6bef9021 52be6d5f
......@@ -46,7 +46,10 @@ public class BalanceManager {
} catch (NoSuchAlgorithmException e) {
log.error("SecureRandom 不可用");
}
int index = secureRandom.nextInt(count);
int index = 0;
if (secureRandom != null) {
index = secureRandom.nextInt(count);
}
List<Server> servers = new ArrayList<>(allServers.values());
return servers.get(index);
}
......
......@@ -22,7 +22,7 @@ public class CommonUtil {
*/
public static String genRandomNum(int length) {
int maxNum = 36;
int i;
int i = -1;
int count = 0;
char[] str = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
......@@ -34,7 +34,9 @@ public class CommonUtil {
log.error("随机生成字符串失败");
}
while (count < length) {
i = Math.abs(secureRandom.nextInt(maxNum));
if (secureRandom != null) {
i = Math.abs(secureRandom.nextInt(maxNum));
}
if (i >= 0 && i < str.length) {
pwd.append(str[i]);
count++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment