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 for standard XMPP connections over TCP."""
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -415,7 +414,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
// bind IQ may trigger a SM ack request, which would be invalid in the pre resource bound state.
|
||||
smEnabledSyncPoint = false;
|
||||
|
||||
List<Stanza> previouslyUnackedStanzas = new LinkedList<Stanza>();
|
||||
List<Stanza> previouslyUnackedStanzas = new ArrayList<Stanza>();
|
||||
if (unacknowledgedStanzas != null) {
|
||||
// There was a previous connection with SM enabled but that was either not resumable or
|
||||
// failed to resume. Make sure that we (re-)send the unacknowledged stanzas.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019-2021 Florian Schmaus
|
||||
* Copyright 2019-2024 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -369,7 +369,7 @@ public class XmppTcpTransportModule extends ModularXmppClientToServerConnectionM
|
|||
newPendingOutputFilterData |= outputResult.pendingFilterData;
|
||||
outputFilterInputData = outputResult.filteredOutputData;
|
||||
if (outputFilterInputData != null) {
|
||||
outputFilterInputData.flip();
|
||||
((java.nio.Buffer) outputFilterInputData).flip();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ public class XmppTcpTransportModule extends ModularXmppClientToServerConnectionM
|
|||
}
|
||||
|
||||
int bytesRead;
|
||||
incomingBuffer.clear();
|
||||
((java.nio.Buffer) incomingBuffer).clear();
|
||||
try {
|
||||
bytesRead = selectedSocketChannel.read(incomingBuffer);
|
||||
} catch (IOException e) {
|
||||
|
@ -503,7 +503,7 @@ public class XmppTcpTransportModule extends ModularXmppClientToServerConnectionM
|
|||
|
||||
ByteBuffer filteredIncomingBuffer = incomingBuffer;
|
||||
for (ListIterator<XmppInputOutputFilter> it = connectionInternal.getXmppInputOutputFilterEndIterator(); it.hasPrevious();) {
|
||||
filteredIncomingBuffer.flip();
|
||||
((java.nio.Buffer) filteredIncomingBuffer).flip();
|
||||
|
||||
ByteBuffer newFilteredIncomingBuffer;
|
||||
try {
|
||||
|
@ -518,7 +518,8 @@ public class XmppTcpTransportModule extends ModularXmppClientToServerConnectionM
|
|||
filteredIncomingBuffer = newFilteredIncomingBuffer;
|
||||
}
|
||||
|
||||
final int bytesReadAfterFilter = filteredIncomingBuffer.flip().remaining();
|
||||
((java.nio.Buffer) filteredIncomingBuffer).flip();
|
||||
final int bytesReadAfterFilter = filteredIncomingBuffer.remaining();
|
||||
|
||||
totalBytesReadAfterFilter += bytesReadAfterFilter;
|
||||
|
||||
|
@ -980,7 +981,7 @@ public class XmppTcpTransportModule extends ModularXmppClientToServerConnectionM
|
|||
|
||||
ByteBuffer[] outputDataArray = pendingOutputData.toArray(new ByteBuffer[pendingOutputData.size()]);
|
||||
|
||||
myNetData.clear();
|
||||
((java.nio.Buffer) myNetData).clear();
|
||||
|
||||
while (true) {
|
||||
SSLEngineResult result;
|
||||
|
@ -1037,7 +1038,7 @@ public class XmppTcpTransportModule extends ModularXmppClientToServerConnectionM
|
|||
newCapacity = 2 * myNetData.capacity();
|
||||
}
|
||||
ByteBuffer newMyNetData = ByteBuffer.allocateDirect(newCapacity);
|
||||
myNetData.flip();
|
||||
((java.nio.Buffer) myNetData).flip();
|
||||
newMyNetData.put(myNetData);
|
||||
myNetData = newMyNetData;
|
||||
continue;
|
||||
|
@ -1060,12 +1061,12 @@ public class XmppTcpTransportModule extends ModularXmppClientToServerConnectionM
|
|||
int accumulatedDataBytes = pendingInputData.remaining() + inputData.remaining();
|
||||
accumulatedData = ByteBuffer.allocate(accumulatedDataBytes);
|
||||
accumulatedData.put(pendingInputData)
|
||||
.put(inputData)
|
||||
.flip();
|
||||
.put(inputData);
|
||||
((java.nio.Buffer) accumulatedData).flip();
|
||||
pendingInputData = null;
|
||||
}
|
||||
|
||||
peerAppData.clear();
|
||||
((java.nio.Buffer) peerAppData).clear();
|
||||
|
||||
while (true) {
|
||||
SSLEngineResult result;
|
||||
|
@ -1143,7 +1144,8 @@ public class XmppTcpTransportModule extends ModularXmppClientToServerConnectionM
|
|||
// higher layer. That is, here 'byteBuffer' is typically 'incomingBuffer', which is a direct buffer only
|
||||
// allocated once per connection for performance reasons and hence re-used for read() calls.
|
||||
pendingInputData = ByteBuffer.allocate(byteBuffer.remaining());
|
||||
pendingInputData.put(byteBuffer).flip();
|
||||
pendingInputData.put(byteBuffer);
|
||||
((java.nio.Buffer) pendingInputData).flip();
|
||||
|
||||
pendingInputFilterData = pendingInputData.hasRemaining();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue