ManagerImpl m = null;
try {
- final var accountPathFinal = accountPath;
m = new ManagerImpl(account,
pathConfig,
- new AccountFileUpdaterImpl(accountsStore, accountPathFinal),
+ new AccountFileUpdaterImpl(accountsStore, accountPath),
serviceEnvironmentConfig,
userAgent);
account = null;
record NoteToSelf() implements RecipientIdentifier {
- public static NoteToSelf INSTANCE = new NoteToSelf();
+ public static final NoteToSelf INSTANCE = new NoteToSelf();
@Override
public String getIdentifier() {
}
public static Builder newBuilder(final UpdateGroup copy) {
- Builder builder = new Builder(copy.name,
+ return new Builder(copy.name,
copy.description,
copy.members,
copy.removeMembers,
copy.avatarFile,
copy.expirationTimer,
copy.isAnnouncementGroup);
- return builder;
}
public static Builder newBuilder(
public void retrieveStickerPack(StickerPackId packId, byte[] packKey) throws InvalidMessageException, IOException {
logger.debug("Retrieving sticker pack {}.", Hex.toStringCondensed(packId.serialize()));
- final var manifest = dependencies.getMessageReceiver().retrieveStickerManifest(packId.serialize(), packKey);
+ final var messageReceiver = dependencies.getMessageReceiver();
+ final var manifest = messageReceiver.retrieveStickerManifest(packId.serialize(), packKey);
final var stickerIds = new HashSet<Integer>();
if (manifest.getCover().isPresent()) {
}
for (var id : stickerIds) {
- final var inputStream = dependencies.getMessageReceiver().retrieveSticker(packId.serialize(), packKey, id);
- context.getStickerPackStore().storeSticker(packId, id, o -> IOUtils.copyStream(inputStream, o));
+ try (final var inputStream = messageReceiver.retrieveSticker(packId.serialize(), packKey, id)) {
+ context.getStickerPackStore().storeSticker(packId, id, o -> IOUtils.copyStream(inputStream, o));
+ }
}
final var jsonManifest = new JsonStickerPack(manifest.getTitle().orElse(null),
}
}
- final Pattern identityFileNamePattern = Pattern.compile("([0-9]+)");
+ final Pattern identityFileNamePattern = Pattern.compile("(\\d+)");
public List<IdentityInfo> getIdentities() {
final var files = identitiesPath.listFiles();
.map(f -> resolver.resolveRecipient(Long.parseLong(f.getName())))
.filter(Objects::nonNull)
.map(this::loadIdentityLocked)
+ .filter(Objects::nonNull)
.toList();
}
return loadSignedPreKeyRecord(file);
}
- final Pattern signedPreKeyFileNamePattern = Pattern.compile("([0-9]+)");
+ final Pattern signedPreKeyFileNamePattern = Pattern.compile("(\\d+)");
@Override
public List<SignedPreKeyRecord> loadSignedPreKeys() {
return parseFileNames(files);
}
- final Pattern senderKeyFileNamePattern = Pattern.compile("([0-9]+)_([0-9]+)_([0-9a-z\\-]+)");
+ final Pattern senderKeyFileNamePattern = Pattern.compile("(\\d+)_(\\d+)_([\\da-z\\-]+)");
private List<Key> parseFileNames(final File[] files) {
return Arrays.stream(files)
return parseFileNames(files);
}
- final Pattern sessionFileNamePattern = Pattern.compile("([0-9]+)_([0-9]+)");
+ final Pattern sessionFileNamePattern = Pattern.compile("(\\d+)_(\\d+)");
private List<Key> parseFileNames(final File[] files) {
return Arrays.stream(files)
final Manager m, final List<String> mentionStrings
) throws UserErrorException {
List<Message.Mention> mentions;
- final Pattern mentionPattern = Pattern.compile("([0-9]+):([0-9]+):(.+)");
+ final Pattern mentionPattern = Pattern.compile("(\\d+):(\\d+):(.+)");
mentions = new ArrayList<>();
for (final var mention : mentionStrings) {
final var matcher = mentionPattern.matcher(mention);
}
private Message.Sticker parseSticker(final String stickerString) throws UserErrorException {
- final Pattern stickerPattern = Pattern.compile("([0-9a-f]+):([0-9]+)");
+ final Pattern stickerPattern = Pattern.compile("([\\da-f]+):(\\d+)");
final var matcher = stickerPattern.matcher(stickerString);
if (!matcher.matches() || matcher.group(1).length() % 2 != 0) {
throw new UserErrorException("Invalid sticker syntax ("