mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-18 01:20:25 +08:00
fix:loadAllIdentifies同时更新VersionMap
This commit is contained in:
@@ -76,10 +76,9 @@ public class IdentityManager {
|
||||
|
||||
public void init() {
|
||||
try{
|
||||
this.identifies = loadAllIdentifies();
|
||||
loadAllIdentifies();
|
||||
this.defaultIdentity = Persist.getDefaultIdentityFromStorage("");
|
||||
this.privateKeyEncryptionAlgorithm = Common.SM4ECB;
|
||||
this.versionMap = new ConcurrentHashMap<>(); // TODO versionMap初始化方式待定
|
||||
}catch (Exception ex){
|
||||
System.out.println(String.format("创建IdentifyManager实例失败:%s", ex.getMessage()));
|
||||
}
|
||||
@@ -88,18 +87,22 @@ public class IdentityManager {
|
||||
|
||||
|
||||
/**
|
||||
* 从sqlite中加载全部网络身份信息并封装成ConcurrentMap
|
||||
* 从sqlite中加载全部网络身份信息并封装成identifies与versionMap
|
||||
* @return {ConcurrentMap}
|
||||
* @throws Exception
|
||||
*/
|
||||
private ConcurrentMap<String, Identity> loadAllIdentifies() throws Exception{
|
||||
private void loadAllIdentifies() throws Exception{
|
||||
List<Identity> identities = Persist.getAllIdentityFromStorage("");
|
||||
ConcurrentHashMap<String, Identity> res = new ConcurrentHashMap<>();
|
||||
ConcurrentHashMap<String, Identity> tempIdentifiesMap = new ConcurrentHashMap<>();
|
||||
ConcurrentHashMap<String, Long> tempVersionMap = new ConcurrentHashMap<>();
|
||||
for (Identity id:
|
||||
identities) {
|
||||
res.put(id.getName(), id);
|
||||
tempIdentifiesMap.put(id.getName(), id);
|
||||
tempVersionMap.put(id.getName(), 0L);
|
||||
}
|
||||
return res;
|
||||
|
||||
this.identifies = tempIdentifiesMap;
|
||||
this.versionMap = tempVersionMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user