mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-20 19:41:31 +00:00
Add synchronized access to cache
This commit is contained in:
parent
ef6a5c69af
commit
6230abb524
@ -34,6 +34,7 @@ public class MessageDisplayHelper {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static String checkCacheForBody(String body) {
|
private static String checkCacheForBody(String body) {
|
||||||
|
synchronized (decryptedBodyCache) {
|
||||||
if (decryptedBodyCache.containsKey(body)) {
|
if (decryptedBodyCache.containsKey(body)) {
|
||||||
String decryptedBody = decryptedBodyCache.get(body).get();
|
String decryptedBody = decryptedBodyCache.get(body).get();
|
||||||
if (decryptedBody != null) {
|
if (decryptedBody != null) {
|
||||||
@ -46,6 +47,7 @@ public class MessageDisplayHelper {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String getDecryptedMessageBody(MasterCipher bodyCipher, String body) throws InvalidMessageException {
|
public static String getDecryptedMessageBody(MasterCipher bodyCipher, String body) throws InvalidMessageException {
|
||||||
if (body.startsWith(Prefix.SYMMETRIC_ENCRYPT)) {
|
if (body.startsWith(Prefix.SYMMETRIC_ENCRYPT)) {
|
||||||
@ -55,7 +57,10 @@ public class MessageDisplayHelper {
|
|||||||
return cacheResult;
|
return cacheResult;
|
||||||
|
|
||||||
String decryptedBody = bodyCipher.decryptBody(body.substring(Prefix.SYMMETRIC_ENCRYPT.length()));
|
String decryptedBody = bodyCipher.decryptBody(body.substring(Prefix.SYMMETRIC_ENCRYPT.length()));
|
||||||
|
|
||||||
|
synchronized (decryptedBodyCache) {
|
||||||
decryptedBodyCache.put(body, new SoftReference<String>(decryptedBody));
|
decryptedBodyCache.put(body, new SoftReference<String>(decryptedBody));
|
||||||
|
}
|
||||||
|
|
||||||
return decryptedBody;
|
return decryptedBody;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user