1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 00:59:39 +02:00

[build] Bump error prone from 2.9.0 to 2.32.0

This commit is contained in:
Florian Schmaus 2024-09-25 21:32:17 +02:00
parent 07d9d694da
commit beacb5eb8e
69 changed files with 265 additions and 255 deletions

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.omemo;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
@ -268,8 +269,9 @@ public class CachingOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Se
}
@Override
@SuppressWarnings("NonApiType")
public TreeMap<Integer, T_PreKey> loadOmemoPreKeys(OmemoDevice userDevice) throws IOException {
TreeMap<Integer, T_PreKey> preKeys = getCache(userDevice).preKeys;
Map<Integer, T_PreKey> preKeys = getCache(userDevice).preKeys;
if (preKeys.isEmpty() && persistent != null) {
preKeys.putAll(persistent.loadOmemoPreKeys(userDevice));
@ -293,8 +295,9 @@ public class CachingOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Se
}
@Override
@SuppressWarnings("NonApiType")
public TreeMap<Integer, T_SigPreKey> loadOmemoSignedPreKeys(OmemoDevice userDevice) throws IOException {
TreeMap<Integer, T_SigPreKey> sigPreKeys = getCache(userDevice).signedPreKeys;
Map<Integer, T_SigPreKey> sigPreKeys = getCache(userDevice).signedPreKeys;
if (sigPreKeys.isEmpty() && persistent != null) {
sigPreKeys.putAll(persistent.loadOmemoSignedPreKeys(userDevice));
@ -341,7 +344,7 @@ public class CachingOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Se
}
@Override
public HashMap<Integer, T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, BareJid contact) throws IOException {
public Map<Integer, T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, BareJid contact) throws IOException {
HashMap<Integer, T_Sess> sessions = getCache(userDevice).sessions.get(contact);
if (sessions == null) {
sessions = new HashMap<>();

View file

@ -200,6 +200,7 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
}
@Override
@SuppressWarnings("NonApiType")
public TreeMap<Integer, T_PreKey> loadOmemoPreKeys(OmemoDevice userDevice) throws IOException {
File preKeyDirectory = hierarchy.getPreKeysDirectory(userDevice);
TreeMap<Integer, T_PreKey> preKeys = new TreeMap<>();
@ -240,6 +241,7 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
}
@Override
@SuppressWarnings("NonApiType")
public TreeMap<Integer, T_SigPreKey> loadOmemoSignedPreKeys(OmemoDevice userDevice) throws IOException {
File signedPreKeysDirectory = hierarchy.getSignedPreKeysDirectory(userDevice);
TreeMap<Integer, T_SigPreKey> signedPreKeys = new TreeMap<>();
@ -296,6 +298,7 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
}
@Override
@SuppressWarnings("NonApiType")
public HashMap<Integer, T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, BareJid contact) throws IOException {
File contactsDirectory = hierarchy.getContactsDir(userDevice, contact);
HashMap<Integer, T_Sess> sessions = new HashMap<>();

View file

@ -25,6 +25,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.SortedSet;
@ -633,7 +634,7 @@ public final class OmemoManager extends Manager {
* @throws SmackException.NoResponseException if there was no response from the remote entity.
* @throws IOException if an I/O error occurred.
*/
public synchronized HashMap<OmemoDevice, OmemoFingerprint> getActiveFingerprints(BareJid contact)
public synchronized Map<OmemoDevice, OmemoFingerprint> getActiveFingerprints(BareJid contact)
throws SmackException.NotLoggedInException, CorruptedOmemoKeyException,
CannotEstablishOmemoSessionException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException, IOException {
@ -641,7 +642,7 @@ public final class OmemoManager extends Manager {
throw new SmackException.NotLoggedInException();
}
HashMap<OmemoDevice, OmemoFingerprint> fingerprints = new HashMap<>();
Map<OmemoDevice, OmemoFingerprint> fingerprints = new HashMap<>();
OmemoCachedDeviceList deviceList = getOmemoService().getOmemoStoreBackend().loadCachedDeviceList(getOwnDevice(),
contact);

View file

@ -22,6 +22,7 @@ import static org.jivesoftware.smackx.omemo.util.OmemoConstants.OMEMO_NAMESPACE_
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.jivesoftware.smack.packet.Message;
@ -78,7 +79,7 @@ public class OmemoMessage {
*/
public static class Sent extends OmemoMessage {
private final Set<OmemoDevice> intendedDevices = new HashSet<>();
private final HashMap<OmemoDevice, Throwable> skippedDevices = new HashMap<>();
private final Map<OmemoDevice, Throwable> skippedDevices = new HashMap<>();
/**
* Create a new outgoing OMEMO message.
@ -90,7 +91,7 @@ public class OmemoMessage {
* @param skippedDevices devices which were skipped during encryption process because encryption
* failed for some reason
*/
Sent(OmemoElement element, byte[] key, byte[] iv, Set<OmemoDevice> intendedDevices, HashMap<OmemoDevice, Throwable> skippedDevices) {
Sent(OmemoElement element, byte[] key, byte[] iv, Set<OmemoDevice> intendedDevices, Map<OmemoDevice, Throwable> skippedDevices) {
super(element, key, iv);
this.intendedDevices.addAll(intendedDevices);
this.skippedDevices.putAll(skippedDevices);
@ -110,7 +111,7 @@ public class OmemoMessage {
*
* @return map of skipped recipients and reasons for that.
*/
public HashMap<OmemoDevice, Throwable> getSkippedDevices() {
public Map<OmemoDevice, Throwable> getSkippedDevices() {
return skippedDevices;
}

View file

@ -30,6 +30,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;
@ -794,7 +795,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
}
// Select random Bundle
HashMap<Integer, T_Bundle> bundlesList = getOmemoStoreBackend().keyUtil().BUNDLE.bundles(bundleElement, contactsDevice);
Map<Integer, T_Bundle> bundlesList = getOmemoStoreBackend().keyUtil().BUNDLE.bundles(bundleElement, contactsDevice);
int randomIndex = new Random().nextInt(bundlesList.size());
T_Bundle randomPreKeyBundle = new ArrayList<>(bundlesList.values()).get(randomIndex);

View file

@ -20,7 +20,6 @@ import static org.jivesoftware.smackx.omemo.util.OmemoConstants.PRE_KEY_COUNT_PE
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeMap;
@ -229,7 +228,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
storeOmemoIdentityKeyPair(userDevice, identityKeyPair);
}
TreeMap<Integer, T_SigPreKey> signedPreKeys = loadOmemoSignedPreKeys(userDevice);
Map<Integer, T_SigPreKey> signedPreKeys = loadOmemoSignedPreKeys(userDevice);
if (signedPreKeys.size() == 0) {
changeSignedPreKey(userDevice);
}
@ -239,7 +238,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
int startId = preKeys.size() == 0 ? 0 : preKeys.lastKey();
if (newKeysCount > 0) {
TreeMap<Integer, T_PreKey> newKeys = generateOmemoPreKeys(startId + 1, newKeysCount);
Map<Integer, T_PreKey> newKeys = generateOmemoPreKeys(startId + 1, newKeysCount);
storeOmemoPreKeys(userDevice, newKeys);
}
}
@ -417,6 +416,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @param count how many keys do we want to generate
* @return Map of new preKeys
*/
@SuppressWarnings("NonApiType")
public TreeMap<Integer, T_PreKey> generateOmemoPreKeys(int startId, int count) {
return keyUtil().generateOmemoPreKeys(startId, count);
}
@ -451,7 +451,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @throws IOException if an I/O error occurred.
*/
public void storeOmemoPreKeys(OmemoDevice userDevice, TreeMap<Integer, T_PreKey> preKeyHashMap) throws IOException {
public void storeOmemoPreKeys(OmemoDevice userDevice, Map<Integer, T_PreKey> preKeyHashMap) throws IOException {
for (Map.Entry<Integer, T_PreKey> entry : preKeyHashMap.entrySet()) {
storeOmemoPreKey(userDevice, entry.getKey(), entry.getValue());
}
@ -474,6 +474,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @throws IOException if an I/O error occurred.
*/
@SuppressWarnings("NonApiType")
public abstract TreeMap<Integer, T_PreKey> loadOmemoPreKeys(OmemoDevice userDevice) throws IOException;
/**
@ -499,6 +500,8 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @throws IOException if an I/O error occurred.
*/
// TreeMap seems to be required for this function.
@SuppressWarnings("NonApiType")
public abstract TreeMap<Integer, T_SigPreKey> loadOmemoSignedPreKeys(OmemoDevice userDevice) throws IOException;
/**
@ -554,7 +557,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
*
* @throws IOException if an I/O error occurred.
*/
public abstract HashMap<Integer, T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, BareJid contact) throws IOException;
public abstract Map<Integer, T_Sess> loadAllRawSessionsOf(OmemoDevice userDevice, BareJid contact) throws IOException;
/**
* Store a crypto-lib specific session to storage.

View file

@ -47,8 +47,8 @@ public abstract class OmemoBundleElement implements ExtensionElement {
private byte[] signedPreKeySignature;
private final String identityKeyB64;
private byte[] identityKey;
private final HashMap<Integer, String> preKeysB64;
private HashMap<Integer, byte[]> preKeys;
private final Map<Integer, String> preKeysB64;
private Map<Integer, byte[]> preKeys;
/**
* Constructor to create a Bundle Element from base64 Strings.
@ -57,9 +57,9 @@ public abstract class OmemoBundleElement implements ExtensionElement {
* @param signedPreKeyB64 base64 encoded signedPreKey
* @param signedPreKeySigB64 base64 encoded signedPreKeySignature
* @param identityKeyB64 base64 encoded identityKey
* @param preKeysB64 HashMap of base64 encoded preKeys
* @param preKeysB64 Map of base64 encoded preKeys
*/
public OmemoBundleElement(int signedPreKeyId, String signedPreKeyB64, String signedPreKeySigB64, String identityKeyB64, HashMap<Integer, String> preKeysB64) {
public OmemoBundleElement(int signedPreKeyId, String signedPreKeyB64, String signedPreKeySigB64, String identityKeyB64, Map<Integer, String> preKeysB64) {
if (signedPreKeyId < 0) {
throw new IllegalArgumentException("signedPreKeyId MUST be greater than or equal to 0.");
}
@ -81,9 +81,9 @@ public abstract class OmemoBundleElement implements ExtensionElement {
* @param signedPreKey signedPreKey
* @param signedPreKeySig signedPreKeySignature
* @param identityKey identityKey
* @param preKeys HashMap of preKeys
* @param preKeys Map of preKeys
*/
public OmemoBundleElement(int signedPreKeyId, byte[] signedPreKey, byte[] signedPreKeySig, byte[] identityKey, HashMap<Integer, byte[]> preKeys) {
public OmemoBundleElement(int signedPreKeyId, byte[] signedPreKey, byte[] signedPreKeySig, byte[] identityKey, Map<Integer, byte[]> preKeys) {
this(signedPreKeyId,
signedPreKey != null ? Base64.encodeToString(signedPreKey) : null,
signedPreKeySig != null ? Base64.encodeToString(signedPreKeySig) : null,
@ -95,12 +95,12 @@ public abstract class OmemoBundleElement implements ExtensionElement {
this.preKeys = preKeys;
}
private static HashMap<Integer, String> base64EncodePreKeys(HashMap<Integer, byte[]> preKeys) {
private static Map<Integer, String> base64EncodePreKeys(Map<Integer, byte[]> preKeys) {
if (preKeys == null) {
return null;
}
HashMap<Integer, String> converted = new HashMap<>();
Map<Integer, String> converted = new HashMap<>();
for (Integer id : preKeys.keySet()) {
converted.put(id, Base64.encodeToString(preKeys.get(id)));
}
@ -155,12 +155,12 @@ public abstract class OmemoBundleElement implements ExtensionElement {
}
/**
* Return the HashMap of preKeys in the bundle.
* Return the Map of preKeys in the bundle.
* The map uses the preKeys ids as key and the preKeys as value.
*
* @return preKeys Pre-Keys contained in the bundle
*/
public HashMap<Integer, byte[]> getPreKeys() {
public Map<Integer, byte[]> getPreKeys() {
if (preKeys == null) {
preKeys = new HashMap<>();
for (int id : preKeysB64.keySet()) {

View file

@ -18,7 +18,7 @@ package org.jivesoftware.smackx.omemo.element;
import static org.jivesoftware.smackx.omemo.util.OmemoConstants.OMEMO_NAMESPACE_V_AXOLOTL;
import java.util.HashMap;
import java.util.Map;
/**
* OMEMO device bundle as described by the protocol.
@ -29,11 +29,11 @@ import java.util.HashMap;
*/
public class OmemoBundleElement_VAxolotl extends OmemoBundleElement {
public OmemoBundleElement_VAxolotl(int signedPreKeyId, String signedPreKeyB64, String signedPreKeySigB64, String identityKeyB64, HashMap<Integer, String> preKeysB64) {
public OmemoBundleElement_VAxolotl(int signedPreKeyId, String signedPreKeyB64, String signedPreKeySigB64, String identityKeyB64, Map<Integer, String> preKeysB64) {
super(signedPreKeyId, signedPreKeyB64, signedPreKeySigB64, identityKeyB64, preKeysB64);
}
public OmemoBundleElement_VAxolotl(int signedPreKeyId, byte[] signedPreKey, byte[] signedPreKeySig, byte[] identityKey, HashMap<Integer, byte[]> preKeys) {
public OmemoBundleElement_VAxolotl(int signedPreKeyId, byte[] signedPreKey, byte[] signedPreKeySig, byte[] identityKey, Map<Integer, byte[]> preKeys) {
super(signedPreKeyId, signedPreKey, signedPreKeySig, identityKey, preKeys);
}

View file

@ -57,7 +57,7 @@ public abstract class OmemoHeaderElement implements XmlElement {
return sid;
}
public ArrayList<OmemoKeyElement> getKeys() {
public List<OmemoKeyElement> getKeys() {
return new ArrayList<>(keys);
}

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smackx.omemo.exceptions;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jivesoftware.smackx.omemo.internal.OmemoDevice;
@ -32,8 +33,8 @@ import org.jxmpp.jid.BareJid;
public class CannotEstablishOmemoSessionException extends Exception {
private static final long serialVersionUID = 3165844730283295249L;
private final HashMap<BareJid, HashMap<OmemoDevice, Throwable>> failures = new HashMap<>();
private final HashMap<BareJid, ArrayList<OmemoDevice>> successes = new HashMap<>();
private final Map<BareJid, Map<OmemoDevice, Throwable>> failures = new HashMap<>();
private final Map<BareJid, List<OmemoDevice>> successes = new HashMap<>();
public CannotEstablishOmemoSessionException(OmemoDevice failed, Throwable reason) {
super();
@ -41,7 +42,7 @@ public class CannotEstablishOmemoSessionException extends Exception {
}
public void addFailures(CannotEstablishOmemoSessionException otherFailures) {
for (Map.Entry<BareJid, HashMap<OmemoDevice, Throwable>> entry : otherFailures.getFailures().entrySet()) {
for (Map.Entry<BareJid, Map<OmemoDevice, Throwable>> entry : otherFailures.getFailures().entrySet()) {
getFailsOfContact(entry.getKey()).putAll(entry.getValue());
}
}
@ -50,16 +51,16 @@ public class CannotEstablishOmemoSessionException extends Exception {
getSuccessesOfContact(success.getJid()).add(success);
}
public HashMap<BareJid, HashMap<OmemoDevice, Throwable>> getFailures() {
public Map<BareJid, Map<OmemoDevice, Throwable>> getFailures() {
return failures;
}
public HashMap<BareJid, ArrayList<OmemoDevice>> getSuccesses() {
public Map<BareJid, List<OmemoDevice>> getSuccesses() {
return successes;
}
private HashMap<OmemoDevice, Throwable> getFailsOfContact(BareJid contact) {
HashMap<OmemoDevice, Throwable> h = failures.get(contact);
private Map<OmemoDevice, Throwable> getFailsOfContact(BareJid contact) {
Map<OmemoDevice, Throwable> h = failures.get(contact);
if (h == null) {
h = new HashMap<>();
failures.put(contact, h);
@ -67,8 +68,8 @@ public class CannotEstablishOmemoSessionException extends Exception {
return h;
}
private ArrayList<OmemoDevice> getSuccessesOfContact(BareJid contact) {
ArrayList<OmemoDevice> suc = successes.get(contact);
private List<OmemoDevice> getSuccessesOfContact(BareJid contact) {
List<OmemoDevice> suc = successes.get(contact);
if (suc == null) {
suc = new ArrayList<>();
successes.put(contact, suc);
@ -83,8 +84,8 @@ public class CannotEstablishOmemoSessionException extends Exception {
* @return true if the exception requires to be thrown
*/
public boolean requiresThrowing() {
for (Map.Entry<BareJid, HashMap<OmemoDevice, Throwable>> entry : failures.entrySet()) {
ArrayList<OmemoDevice> suc = successes.get(entry.getKey());
for (Map.Entry<BareJid, Map<OmemoDevice, Throwable>> entry : failures.entrySet()) {
List<OmemoDevice> suc = successes.get(entry.getKey());
if (suc == null || suc.isEmpty()) {
return true;
}

View file

@ -119,8 +119,8 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
*
* @throws CorruptedOmemoKeyException when one of the keys cannot be parsed
*/
public HashMap<Integer, T_Bundle> bundles(OmemoBundleElement bundle, OmemoDevice contact) throws CorruptedOmemoKeyException {
HashMap<Integer, T_Bundle> bundles = new HashMap<>();
public Map<Integer, T_Bundle> bundles(OmemoBundleElement bundle, OmemoDevice contact) throws CorruptedOmemoKeyException {
Map<Integer, T_Bundle> bundles = new HashMap<>();
for (int deviceId : bundle.getPreKeys().keySet()) {
try {
bundles.put(deviceId, bundleFromOmemoBundle(bundle, contact, deviceId));
@ -211,6 +211,8 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param count how many keys do we want to generate
* @return Map of new preKeys
*/
// We use TreeMap.lastKey()
@SuppressWarnings("NonApiType")
public abstract TreeMap<Integer, T_PreKey> generateOmemoPreKeys(int startId, int count);
/**
@ -338,8 +340,8 @@ public abstract class OmemoKeyUtil<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
* @param preKeyHashMap HashMap of preKeys
* @return HashMap of byte arrays but with the same keyIds as key
*/
public HashMap<Integer, byte[]> preKeyPublicKeysForBundle(TreeMap<Integer, T_PreKey> preKeyHashMap) {
HashMap<Integer, byte[]> out = new HashMap<>();
public Map<Integer, byte[]> preKeyPublicKeysForBundle(Map<Integer, T_PreKey> preKeyHashMap) {
Map<Integer, byte[]> out = new HashMap<>();
for (Map.Entry<Integer, T_PreKey> e : preKeyHashMap.entrySet()) {
out.put(e.getKey(), preKeyForBundle(e.getValue()));
}

File diff suppressed because one or more lines are too long

View file

@ -27,8 +27,8 @@ import static junit.framework.TestCase.assertTrue;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.TreeMap;
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
@ -174,7 +174,7 @@ public abstract class OmemoStoreTest<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey
public void storeLoadRemoveOmemoPreKeys()
throws IOException, InterruptedException {
TreeMap<Integer, T_PreKey> before = store.generateOmemoPreKeys(1, 10);
Map<Integer, T_PreKey> before = store.generateOmemoPreKeys(1, 10);
assertEquals("The store must have no prekeys before this test.", 0, store.loadOmemoPreKeys(alice).size());
store.storeOmemoPreKeys(alice, before);
@ -305,7 +305,7 @@ public abstract class OmemoStoreTest<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey
@Test
public void loadAllRawSessionsReturnsEmptyMapTest() throws IOException {
HashMap<Integer, T_Sess> sessions = store.loadAllRawSessionsOf(alice, bob.getJid());
Map<Integer, T_Sess> sessions = store.loadAllRawSessionsOf(alice, bob.getJid());
assertNotNull(sessions);
assertEquals(0, sessions.size());
}