Fix inspection issues

This commit is contained in:
AsamK 2022-05-26 12:23:21 +02:00
parent b178c7c67a
commit d8d859ab02
9 changed files with 15 additions and 14 deletions

View file

@ -150,10 +150,9 @@ class ProvisioningManagerImpl implements ProvisioningManager {
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;

View file

@ -15,7 +15,7 @@ public sealed interface RecipientIdentifier {
record NoteToSelf() implements RecipientIdentifier {
public static NoteToSelf INSTANCE = new NoteToSelf();
public static final NoteToSelf INSTANCE = new NoteToSelf();
@Override
public String getIdentifier() {

View file

@ -47,7 +47,7 @@ public class UpdateGroup {
}
public static Builder newBuilder(final UpdateGroup copy) {
Builder builder = new Builder(copy.name,
return new Builder(copy.name,
copy.description,
copy.members,
copy.removeMembers,
@ -62,7 +62,6 @@ public class UpdateGroup {
copy.avatarFile,
copy.expirationTimer,
copy.isAnnouncementGroup);
return builder;
}
public static Builder newBuilder(

View file

@ -49,7 +49,8 @@ public class StickerHelper {
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()) {
@ -60,9 +61,10 @@ public class StickerHelper {
}
for (var id : stickerIds) {
final var inputStream = dependencies.getMessageReceiver().retrieveSticker(packId.serialize(), packKey, id);
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),
manifest.getAuthor().orElse(null),

View file

@ -186,7 +186,7 @@ public class IdentityKeyStore implements org.signal.libsignal.protocol.state.Ide
}
}
final Pattern identityFileNamePattern = Pattern.compile("([0-9]+)");
final Pattern identityFileNamePattern = Pattern.compile("(\\d+)");
public List<IdentityInfo> getIdentities() {
final var files = identitiesPath.listFiles();
@ -198,6 +198,7 @@ public class IdentityKeyStore implements org.signal.libsignal.protocol.state.Ide
.map(f -> resolver.resolveRecipient(Long.parseLong(f.getName())))
.filter(Objects::nonNull)
.map(this::loadIdentityLocked)
.filter(Objects::nonNull)
.toList();
}

View file

@ -36,7 +36,7 @@ public class SignedPreKeyStore implements org.signal.libsignal.protocol.state.Si
return loadSignedPreKeyRecord(file);
}
final Pattern signedPreKeyFileNamePattern = Pattern.compile("([0-9]+)");
final Pattern signedPreKeyFileNamePattern = Pattern.compile("(\\d+)");
@Override
public List<SignedPreKeyRecord> loadSignedPreKeys() {

View file

@ -161,7 +161,7 @@ public class SenderKeyRecordStore implements org.signal.libsignal.protocol.group
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)

View file

@ -242,7 +242,7 @@ public class SessionStore implements SignalServiceSessionStore {
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)

View file

@ -189,7 +189,7 @@ public class SendCommand implements JsonRpcLocalCommand {
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);
@ -205,7 +205,7 @@ public class SendCommand implements JsonRpcLocalCommand {
}
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 ("