mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
fix:loadAllIdentifies同时更新VersionMap
This commit is contained in:
1 parent
31e995af1c
commit
d117f5359b
1 file changed
+10
-7
@@ -76,10 +76,9 @@ public class IdentityManager {
|
|||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
try{
|
try{
|
||||||
this.identifies = loadAllIdentifies();
|
loadAllIdentifies();
|
||||||
this.defaultIdentity = Persist.getDefaultIdentityFromStorage("");
|
this.defaultIdentity = Persist.getDefaultIdentityFromStorage("");
|
||||||
this.privateKeyEncryptionAlgorithm = Common.SM4ECB;
|
this.privateKeyEncryptionAlgorithm = Common.SM4ECB;
|
||||||
this.versionMap = new ConcurrentHashMap<>(); // TODO versionMap初始化方式待定
|
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
System.out.println(String.format("创建IdentifyManager实例失败:%s", ex.getMessage()));
|
System.out.println(String.format("创建IdentifyManager实例失败:%s", ex.getMessage()));
|
||||||
}
|
}
|
||||||
@@ -88,18 +87,22 @@ public class IdentityManager {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从sqlite中加载全部网络身份信息并封装成ConcurrentMap
|
* 从sqlite中加载全部网络身份信息并封装成identifies与versionMap
|
||||||
* @return {ConcurrentMap}
|
* @return {ConcurrentMap}
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private ConcurrentMap<String, Identity> loadAllIdentifies() throws Exception{
|
private void loadAllIdentifies() throws Exception{
|
||||||
List<Identity> identities = Persist.getAllIdentityFromStorage("");
|
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:
|
for (Identity id:
|
||||||
identities) {
|
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