return null;
}
+ profile = decryptProfileIfKeyKnown(recipientId, encryptedProfile);
+ account.getProfileStore().storeProfile(recipientId, profile);
+
+ return profile;
+ }
+
+ private Profile decryptProfileIfKeyKnown(
+ final RecipientId recipientId, final SignalServiceProfile encryptedProfile
+ ) {
var profileKey = account.getProfileStore().getProfileKey(recipientId);
if (profileKey == null) {
- profile = new Profile(System.currentTimeMillis(),
+ return new Profile(System.currentTimeMillis(),
null,
null,
null,
null,
ProfileUtils.getUnidentifiedAccessMode(encryptedProfile, null),
ProfileUtils.getCapabilities(encryptedProfile));
- } else {
- profile = decryptProfileAndDownloadAvatar(recipientId, profileKey, encryptedProfile);
}
- account.getProfileStore().storeProfile(recipientId, profile);
- return profile;
+ return decryptProfileAndDownloadAvatar(recipientId, profileKey, encryptedProfile);
}
private SignalServiceProfile retrieveEncryptedProfile(RecipientId recipientId) {
try {
action.execute(this);
} catch (Throwable e) {
+ if (e instanceof AssertionError && e.getCause() instanceof InterruptedException) {
+ Thread.currentThread().interrupt();
+ }
logger.warn("Message action failed.", e);
}
}
boolean returnOnTimeout,
boolean ignoreAttachments,
ReceiveMessageHandler handler
- ) throws IOException {
+ ) throws IOException, InterruptedException {
retryFailedReceivedMessages(handler, ignoreAttachments);
Set<HandleAction> queuedActions = null;
var hasCaughtUpWithOldMessages = false;
- while (true) {
+ while (!Thread.interrupted()) {
SignalServiceEnvelope envelope;
SignalServiceContent content = null;
Exception exception = null;
try {
action.execute(this);
} catch (Throwable e) {
+ if (e instanceof AssertionError && e.getCause() instanceof InterruptedException) {
+ Thread.currentThread().interrupt();
+ }
logger.warn("Message action failed.", e);
}
}
// Continue to wait another timeout for new messages
continue;
}
+ } catch (AssertionError e) {
+ if (e.getCause() instanceof InterruptedException) {
+ throw (InterruptedException) e.getCause();
+ } else {
+ throw e;
+ }
} catch (TimeoutException e) {
if (returnOnTimeout) return;
continue;
try {
action.execute(this);
} catch (Throwable e) {
+ if (e instanceof AssertionError && e.getCause() instanceof InterruptedException) {
+ Thread.currentThread().interrupt();
+ }
logger.warn("Message action failed.", e);
}
}
avatarStore.storeProfileAvatar(address,
outputStream -> retrieveProfileAvatar(avatarPath, profileKey, outputStream));
} catch (Throwable e) {
+ if (e instanceof AssertionError && e.getCause() instanceof InterruptedException) {
+ Thread.currentThread().interrupt();
+ }
logger.warn("Failed to download profile avatar, ignoring: {}", e.getMessage());
}
}