mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 00:59:39 +02:00
Bump to Gradle 8.10.2, require Java 11
Bump Gradle from 6.8.3 to 8.10.2 and increase the minimum required Java version from 8 to 11 (SMACK-953). The switch from Java 8 to 11 caused some Bytecode portability issues regarding NIO Buffers. Java changed with version 9 the return type of some subclasses of Buffer to return the specific Buffer type instead of the Buffer superclass [JDK-4774077]. For example, ByteBuffer.filp() previously returned Buffer, while it does return ByteBuffer now. This sensible change was not reflected by the Android API [1], which means that AnimalSniffer rightfully started to complain that there is no method "ByteBuffer ByteBuffer.flip()" in Android, there is only "Buffer ByteBuffer.flip()", and those are incompatible methods on Java's Bytecode layer. As workaround, this changes return charBuffer.flip().toString(); to ((java.nio.Buffer) charBuffer).flip(); return charBuffer.toString(); to restore the Bytecode portability between Android and Java. Errorprone also got new checks, of which JavaUtilDate and JdkObsolete are wroth mentioning. JavaUtilData basically strongly recommends to use Java's newer time API over java.util.Date. But since Smack was Java 8 until now, j.u.Date is widely used. Similar JdkObsolete mentions obsolete JDK APIs, like data structures like Vector and Stack. But mostly LinkedList, which should usually be replaced by ArrayList. And this is what this commit largely does. JDK-4774077: https://bugs.openjdk.org/browse/JDK-4774077 1: https://issuetracker.google.com/issues/369219141
This commit is contained in:
parent
d8d066b831
commit
1e5d34eacf
136 changed files with 1161 additions and 1220 deletions
|
@ -1,3 +1,8 @@
|
|||
plugins {
|
||||
id 'org.igniterealtime.smack.java-common-conventions'
|
||||
id 'org.igniterealtime.smack.android-conventions'
|
||||
}
|
||||
|
||||
description="""
|
||||
Smack API for XEP-0384: OMEMO Encryption
|
||||
"""
|
||||
|
@ -7,5 +12,8 @@ dependencies {
|
|||
api project(":smack-extensions")
|
||||
api project(":smack-experimental")
|
||||
|
||||
// TODO: Migrate Junit4 tests to Junit5.
|
||||
testImplementation "org.junit.vintage:junit-vintage-engine:$junitVersion"
|
||||
|
||||
testFixturesApi(testFixtures(project(":smack-core")))
|
||||
}
|
||||
|
|
|
@ -125,12 +125,14 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
public void setDateOfLastReceivedMessage(OmemoDevice userDevice, OmemoDevice contactsDevice, Date date) throws IOException {
|
||||
File lastMessageReceived = hierarchy.getLastMessageReceivedDatePath(userDevice, contactsDevice);
|
||||
writeLong(lastMessageReceived, date.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
public Date getDateOfLastReceivedMessage(OmemoDevice userDevice, OmemoDevice contactsDevice) throws IOException {
|
||||
File lastMessageReceived = hierarchy.getLastMessageReceivedDatePath(userDevice, contactsDevice);
|
||||
Long date = readLong(lastMessageReceived);
|
||||
|
@ -138,12 +140,14 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
public void setDateOfLastDeviceIdPublication(OmemoDevice userDevice, OmemoDevice contactsDevice, Date date) throws IOException {
|
||||
File lastDeviceIdPublished = hierarchy.getLastDeviceIdPublicationDatePath(userDevice, contactsDevice);
|
||||
writeLong(lastDeviceIdPublished, date.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
public Date getDateOfLastDeviceIdPublication(OmemoDevice userDevice, OmemoDevice contactsDevice) throws IOException {
|
||||
File lastDeviceIdPublished = hierarchy.getLastDeviceIdPublicationDatePath(userDevice, contactsDevice);
|
||||
Long date = readLong(lastDeviceIdPublished);
|
||||
|
@ -151,12 +155,14 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
public void setDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice, Date date) throws IOException {
|
||||
File lastSignedPreKeyRenewal = hierarchy.getLastSignedPreKeyRenewal(userDevice);
|
||||
writeLong(lastSignedPreKeyRenewal, date.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
public Date getDateOfLastSignedPreKeyRenewal(OmemoDevice userDevice) throws IOException {
|
||||
File lastSignedPreKeyRenewal = hierarchy.getLastSignedPreKeyRenewal(userDevice);
|
||||
Long date = readLong(lastSignedPreKeyRenewal);
|
||||
|
@ -517,6 +523,7 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
|
|||
* Delete a directory with all subdirectories.
|
||||
* @param root directory to be deleted
|
||||
*/
|
||||
@SuppressWarnings("JdkObsolete")
|
||||
public static void deleteDirectory(File root) {
|
||||
File[] currList;
|
||||
Stack<File> stack = new Stack<>();
|
||||
|
|
|
@ -914,6 +914,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
|||
*
|
||||
* @throws IOException if an I/O error occurred.
|
||||
*/
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
private boolean shouldRotateSignedPreKey(OmemoDevice userDevice) throws IOException {
|
||||
if (!OmemoConfiguration.getRenewOldSignedPreKeys()) {
|
||||
return false;
|
||||
|
@ -965,6 +966,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
|||
*
|
||||
* @throws IOException if an I/O error occurred.
|
||||
*/
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
private OmemoCachedDeviceList removeStaleDevicesFromDeviceList(OmemoDevice userDevice,
|
||||
BareJid contact,
|
||||
OmemoCachedDeviceList contactsDeviceList,
|
||||
|
@ -1020,6 +1022,7 @@ public abstract class OmemoService<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey,
|
|||
*
|
||||
* @return true if the subject device is considered stale
|
||||
*/
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
static boolean isStale(OmemoDevice userDevice, OmemoDevice subject, Date lastReceipt, int maxAgeHours) {
|
||||
if (userDevice.equals(subject)) {
|
||||
return false;
|
||||
|
|
|
@ -109,6 +109,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
|
|||
*
|
||||
* @throws IOException if an I/O error occurred.
|
||||
*/
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
OmemoCachedDeviceList mergeCachedDeviceList(OmemoDevice userDevice, BareJid contact, OmemoDeviceListElement list) throws IOException {
|
||||
OmemoCachedDeviceList cached = loadCachedDeviceList(userDevice, contact);
|
||||
|
||||
|
@ -142,6 +143,7 @@ public abstract class OmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
|
|||
* @throws IOException if an I/O error occurred.
|
||||
* @throws IllegalStateException when our IdentityKeyPair is null.
|
||||
*/
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
void changeSignedPreKey(OmemoDevice userDevice)
|
||||
throws CorruptedOmemoKeyException, IOException {
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ public class OmemoServiceTest extends SmackTestSuite {
|
|||
* @throws XmppStringprepException if the provided string is invalid.
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("JavaUtilDate")
|
||||
public void isStaleDeviceTest() throws XmppStringprepException {
|
||||
OmemoDevice user = new OmemoDevice(JidCreate.bareFrom("alice@wonderland.lit"), 123);
|
||||
OmemoDevice other = new OmemoDevice(JidCreate.bareFrom("bob@builder.tv"), 444);
|
||||
|
|
|
@ -247,8 +247,8 @@ public abstract class OmemoStoreTest<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey
|
|||
assertEquals(0, store.loadOmemoSignedPreKeys(alice).size());
|
||||
}
|
||||
|
||||
@SuppressWarnings("UndefinedEquals")
|
||||
@Test
|
||||
@SuppressWarnings({"UndefinedEquals", "JavaUtilDate"})
|
||||
public void loadStoreDateOfLastSignedPreKeyRenewal() throws IOException {
|
||||
assertNull("The date of last signed preKey renewal must be null at this stage.",
|
||||
store.getDateOfLastSignedPreKeyRenewal(alice));
|
||||
|
@ -258,8 +258,8 @@ public abstract class OmemoStoreTest<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey
|
|||
assertEquals("Dates must equal.", after, before);
|
||||
}
|
||||
|
||||
@SuppressWarnings("UndefinedEquals")
|
||||
@Test
|
||||
@SuppressWarnings({"UndefinedEquals", "JavaUtilDate"})
|
||||
public void loadStoreDateOfLastMessageReceived() throws IOException {
|
||||
assertNull("The date of last message received must be null at this stage.",
|
||||
store.getDateOfLastReceivedMessage(alice, bob));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue