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; ManagerImpl m = null;
try { try {
final var accountPathFinal = accountPath;
m = new ManagerImpl(account, m = new ManagerImpl(account,
pathConfig, pathConfig,
new AccountFileUpdaterImpl(accountsStore, accountPathFinal), new AccountFileUpdaterImpl(accountsStore, accountPath),
serviceEnvironmentConfig, serviceEnvironmentConfig,
userAgent); userAgent);
account = null; account = null;

View file

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

View file

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

View file

@ -49,7 +49,8 @@ public class StickerHelper {
public void retrieveStickerPack(StickerPackId packId, byte[] packKey) throws InvalidMessageException, IOException { public void retrieveStickerPack(StickerPackId packId, byte[] packKey) throws InvalidMessageException, IOException {
logger.debug("Retrieving sticker pack {}.", Hex.toStringCondensed(packId.serialize())); 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>(); final var stickerIds = new HashSet<Integer>();
if (manifest.getCover().isPresent()) { if (manifest.getCover().isPresent()) {
@ -60,8 +61,9 @@ public class StickerHelper {
} }
for (var id : stickerIds) { 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)); context.getStickerPackStore().storeSticker(packId, id, o -> IOUtils.copyStream(inputStream, o));
}
} }
final var jsonManifest = new JsonStickerPack(manifest.getTitle().orElse(null), final var jsonManifest = new JsonStickerPack(manifest.getTitle().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() { public List<IdentityInfo> getIdentities() {
final var files = identitiesPath.listFiles(); 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()))) .map(f -> resolver.resolveRecipient(Long.parseLong(f.getName())))
.filter(Objects::nonNull) .filter(Objects::nonNull)
.map(this::loadIdentityLocked) .map(this::loadIdentityLocked)
.filter(Objects::nonNull)
.toList(); .toList();
} }

View file

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

View file

@ -161,7 +161,7 @@ public class SenderKeyRecordStore implements org.signal.libsignal.protocol.group
return parseFileNames(files); 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) { private List<Key> parseFileNames(final File[] files) {
return Arrays.stream(files) return Arrays.stream(files)

View file

@ -242,7 +242,7 @@ public class SessionStore implements SignalServiceSessionStore {
return parseFileNames(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) { private List<Key> parseFileNames(final File[] files) {
return Arrays.stream(files) return Arrays.stream(files)

View file

@ -189,7 +189,7 @@ public class SendCommand implements JsonRpcLocalCommand {
final Manager m, final List<String> mentionStrings final Manager m, final List<String> mentionStrings
) throws UserErrorException { ) throws UserErrorException {
List<Message.Mention> mentions; List<Message.Mention> mentions;
final Pattern mentionPattern = Pattern.compile("([0-9]+):([0-9]+):(.+)"); final Pattern mentionPattern = Pattern.compile("(\\d+):(\\d+):(.+)");
mentions = new ArrayList<>(); mentions = new ArrayList<>();
for (final var mention : mentionStrings) { for (final var mention : mentionStrings) {
final var matcher = mentionPattern.matcher(mention); final var matcher = mentionPattern.matcher(mention);
@ -205,7 +205,7 @@ public class SendCommand implements JsonRpcLocalCommand {
} }
private Message.Sticker parseSticker(final String stickerString) throws UserErrorException { 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); final var matcher = stickerPattern.matcher(stickerString);
if (!matcher.matches() || matcher.group(1).length() % 2 != 0) { if (!matcher.matches() || matcher.group(1).length() % 2 != 0) {
throw new UserErrorException("Invalid sticker syntax (" throw new UserErrorException("Invalid sticker syntax ("