按主键散列,未设置主键时无限空指针异常 (#1889)

当按注解散列时,如果监控的表未显示设置主键,将会导致flatMessage.getPkNames()为空,导致无限空指针异常
This commit is contained in:
Z6N
2019-06-18 15:01:00 +08:00
committed by agapple
parent 75b4911caf
commit 5ac0f7b710

View File

@@ -446,12 +446,14 @@ public class MQMessageUtils {
int idx = 0;
for (Map<String, String> row : flatMessage.getData()) {
int hashCode = database.hashCode();
for (String pkName : pkNames) {
String value = row.get(pkName);
if (value == null) {
value = "";
if (pkNames != null) {
for (String pkName : pkNames) {
String value = row.get(pkName);
if (value == null) {
value = "";
}
hashCode = hashCode ^ value.hashCode();
}
hashCode = hashCode ^ value.hashCode();
}
int pkHash = Math.abs(hashCode) % partitionsNum;