1
0
Fork 0
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:
Florian Schmaus 2024-09-25 11:43:47 +02:00
parent d8d066b831
commit 1e5d34eacf
136 changed files with 1161 additions and 1220 deletions

View file

@ -1,7 +1,7 @@
// Note that this is also declared in the main build.gradle for
// subprojects, but since evaluationDependsOnChildren is enabled we
// need to declare it here too to have bundle{bnd{...}} available
apply plugin: 'biz.aQute.bnd.builder'
plugins {
id 'org.igniterealtime.smack.java-common-conventions'
id 'org.igniterealtime.smack.android-conventions'
}
description = """\
Smack core components."""
@ -16,6 +16,9 @@ dependencies {
api "org.jxmpp:jxmpp-jid:$jxmppVersion"
api "org.minidns:minidns-core:$miniDnsVersion"
// TODO: Migrate Junit4 tests to Junit5.
testImplementation "org.junit.vintage:junit-vintage-engine:$junitVersion"
testFixturesImplementation project(':smack-xmlparser-stax')
testFixturesImplementation project(':smack-xmlparser-xpp3')
@ -59,7 +62,7 @@ task createVersionResource(type: CreateFileTask) {
outputFile = new File(projectDir, 'src/main/resources/org.jivesoftware.smack/version')
}
compileJava.dependsOn(createVersionResource)
processResources.dependsOn(createVersionResource)
jar {
bundle {

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2009 Jive Software, 2018-2022 Florian Schmaus.
* Copyright 2009 Jive Software, 2018-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.
@ -19,6 +19,7 @@ package org.jivesoftware.smack;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@ -1067,6 +1068,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
@Override
@SuppressWarnings("TypeParameterUnusedInFormals")
public <I extends IQ> I sendIqRequestAndWaitForResponse(IQ request)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
StanzaCollector collector = createStanzaCollectorAndSend(request);
@ -1214,7 +1216,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
Stanza packet = (Stanza) sendTopLevelStreamElement;
final List<StanzaListener> listenersToNotify = new LinkedList<>();
final List<StanzaListener> listenersToNotify = new ArrayList<>();
synchronized (sendListeners) {
for (ListenerWrapper listenerWrapper : sendListeners.values()) {
if (listenerWrapper.filterMatches(packet)) {
@ -1284,7 +1286,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
private static <MPB extends MessageOrPresenceBuilder<MP, MPB>, MP extends MessageOrPresence<MPB>> MP fireMessageOrPresenceInterceptors(
MP messageOrPresence, Map<Consumer<MPB>, GenericInterceptorWrapper<MPB, MP>> interceptors) {
List<Consumer<MPB>> interceptorsToInvoke = new LinkedList<>();
List<Consumer<MPB>> interceptorsToInvoke = new ArrayList<>();
synchronized (interceptors) {
for (GenericInterceptorWrapper<MPB, MP> interceptorWrapper : interceptors.values()) {
if (interceptorWrapper.filterMatches(messageOrPresence)) {
@ -1319,7 +1321,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @return the, potentially modified stanza, after the interceptors are run.
*/
private Stanza firePacketInterceptors(Stanza packet) {
List<StanzaListener> interceptorsToInvoke = new LinkedList<>();
List<StanzaListener> interceptorsToInvoke = new ArrayList<>();
synchronized (interceptors) {
for (InterceptorWrapper interceptorWrapper : interceptors.values()) {
if (interceptorWrapper.filterMatches(packet)) {
@ -1604,7 +1606,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// First handle the async recv listeners. Note that this code is very similar to what follows a few lines below,
// the only difference is that asyncRecvListeners is used here and that the packet listeners are started in
// their own thread.
final Collection<StanzaListener> listenersToNotify = new LinkedList<>();
final Collection<StanzaListener> listenersToNotify = new ArrayList<>();
extractMatchingListeners(packet, asyncRecvListeners, listenersToNotify);
for (final StanzaListener listener : listenersToNotify) {
asyncGoLimited(new Runnable() {
@ -1930,7 +1932,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// Default implementation does nothing
}
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
@Override
public <F extends XmlElement> F getFeature(QName qname) {
return (F) streamFeatures.get(qname);
@ -2175,6 +2177,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* {@link #maxAsyncRunnables}. Note that we use a {@code LinkedList} in order to avoid space blowups in case the
* list ever becomes very big and shrinks again.
*/
@SuppressWarnings("JdkObsolete")
private final Queue<Runnable> deferredAsyncRunnables = new LinkedList<>();
private int deferredAsyncRunnablesCount;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2018 Florian Schmaus
* Copyright 2018-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.
@ -50,11 +50,13 @@ public class ScheduledAction implements Delayed {
return smackReactor.cancel(this);
}
@SuppressWarnings("JavaUtilDate")
public boolean isDue() {
Date now = new Date();
return now.after(releaseTime);
}
@SuppressWarnings("JavaUtilDate")
public long getTimeToDueMillis() {
long now = System.currentTimeMillis();
return releaseTime.getTime() - now;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2018-2023 Florian Schmaus
* Copyright 2018-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.
@ -144,6 +144,7 @@ public class SmackReactor {
}
}
@SuppressWarnings("JavaUtilDate")
ScheduledAction schedule(Runnable runnable, long delay, TimeUnit unit, ScheduledAction.Kind scheduledActionKind) {
long releaseTimeEpoch = System.currentTimeMillis() + unit.toMillis(delay);
Date releaseTimeDate = new Date(releaseTimeEpoch);

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software, 2016-2019 Florian Schmaus.
* Copyright 2003-2007 Jive Software, 2016-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.
@ -117,7 +117,7 @@ public final class StanzaCollector implements AutoCloseable {
* @return the next stanza result, or <code>null</code> if there are no more
* results.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
public synchronized <P extends Stanza> P pollResult() {
return (P) resultQueue.poll();
}
@ -134,6 +134,7 @@ public final class StanzaCollector implements AutoCloseable {
* @return the next available packet.
* @throws XMPPErrorException in case an error response.
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
public <P extends Stanza> P pollResultOrThrow() throws XMPPErrorException {
P result = pollResult();
if (result != null) {
@ -150,7 +151,7 @@ public final class StanzaCollector implements AutoCloseable {
* @return the next available packet.
* @throws InterruptedException if the calling thread was interrupted.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
// TODO: Consider removing this method as it is hardly ever useful.
public synchronized <P extends Stanza> P nextResultBlockForever() throws InterruptedException {
throwIfCancelled();
@ -175,6 +176,7 @@ public final class StanzaCollector implements AutoCloseable {
* @return the next available packet.
* @throws InterruptedException if the calling thread was interrupted.
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
public <P extends Stanza> P nextResult() throws InterruptedException {
return nextResult(connection.getReplyTimeout());
}
@ -191,7 +193,7 @@ public final class StanzaCollector implements AutoCloseable {
* @return the next available stanza or <code>null</code> on timeout or connection error.
* @throws InterruptedException if the calling thread was interrupted.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
public <P extends Stanza> P nextResult(long timeout) throws InterruptedException {
throwIfCancelled();
P res = null;
@ -223,6 +225,7 @@ public final class StanzaCollector implements AutoCloseable {
* @throws NotConnectedException if the XMPP connection is not connected.
* @see #nextResultOrThrow(long)
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
public <P extends Stanza> P nextResultOrThrow() throws NoResponseException, XMPPErrorException,
InterruptedException, NotConnectedException {
return nextResultOrThrow(connection.getReplyTimeout());
@ -263,6 +266,7 @@ public final class StanzaCollector implements AutoCloseable {
* @throws InterruptedException if the calling thread was interrupted.
* @throws NotConnectedException if there was no response and the connection got disconnected.
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
public <P extends Stanza> P nextResultOrThrow(long timeout) throws NoResponseException,
XMPPErrorException, InterruptedException, NotConnectedException {
P result;

View file

@ -318,6 +318,7 @@ public interface XMPPConnection {
* @throws InterruptedException if the calling thread was interrupted.
* @since 4.3
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
<I extends IQ> I sendIqRequestAndWaitForResponse(IQ request)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException;
@ -590,6 +591,7 @@ public interface XMPPConnection {
* @return a stanza extensions of the feature or <code>null</code>
* @since 4.4
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
<F extends XmlElement> F getFeature(QName qname);
/**

View file

@ -301,7 +301,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
currentStateVertex = StateDescriptorGraph.convertToStateGraph(initialStateDescriptorVertex, connectionInternal);
}
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
public <CM extends ModularXmppClientToServerConnectionModule<? extends ModularXmppClientToServerConnectionModuleDescriptor>> CM getConnectionModuleFor(
Class<? extends ModularXmppClientToServerConnectionModuleDescriptor> descriptorClass) {
return (CM) connectionModules.get(descriptorClass);

View file

@ -143,7 +143,9 @@ public final class ZlibXmppCompressionFactory extends XmppCompressionFactory {
int bytesWritten = compressor.deflate(buffer, initialOutputBufferPosition, length, flushMode);
int newOutputBufferPosition = initialOutputBufferPosition + bytesWritten;
outputBuffer.position(newOutputBufferPosition);
// Workaround for Android API not matching Java >=9 API.
// See https://issuetracker.google.com/issues/369219141
((java.nio.Buffer) outputBuffer).position(newOutputBufferPosition);
totalBytesWritten += bytesWritten;
@ -156,7 +158,9 @@ public final class ZlibXmppCompressionFactory extends XmppCompressionFactory {
increasedBufferSize = MINIMUM_OUTPUT_BUFFER_INCREASE;
}
ByteBuffer newCurrentOutputBuffer = ByteBuffer.allocate(increasedBufferSize);
outputBuffer.flip();
// Workaround for Android API not matching Java >=9 API.
// See https://issuetracker.google.com/issues/369219141
((java.nio.Buffer) outputBuffer).flip();
newCurrentOutputBuffer.put(outputBuffer);
outputBuffer = newCurrentOutputBuffer;
}
@ -202,7 +206,9 @@ public final class ZlibXmppCompressionFactory extends XmppCompressionFactory {
throw new IOException(e);
}
outputBuffer.position(inflateOutputBufferOffset + bytesInflated);
// Workaround for Android API not matching Java >=9 API.
// See https://issuetracker.google.com/issues/369219141
((java.nio.Buffer) outputBuffer).position(inflateOutputBufferOffset + bytesInflated);
decompressorOutBytes += bytesInflated;
@ -212,7 +218,9 @@ public final class ZlibXmppCompressionFactory extends XmppCompressionFactory {
int increasedBufferSize = outputBuffer.capacity() * 2;
ByteBuffer increasedOutputBuffer = ByteBuffer.allocate(increasedBufferSize);
outputBuffer.flip();
// Workaround for Android API not matching Java >=9 API.
// See https://issuetracker.google.com/issues/369219141
((java.nio.Buffer) outputBuffer).flip();
increasedOutputBuffer.put(outputBuffer);
outputBuffer = increasedOutputBuffer;
}

View file

@ -41,6 +41,7 @@ public class ConsoleDebugger extends AbstractDebugger {
super(connection);
}
@SuppressWarnings("JavaUtilDate")
@Override
protected void log(String logMessage) {
String formatedDate;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2014-2018 Florian Schmaus
* Copyright 2014-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.
@ -18,7 +18,7 @@ package org.jivesoftware.smack.initializer;
import java.io.InputStream;
import java.net.URI;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -42,7 +42,7 @@ public abstract class UrlInitializer implements SmackInitializer {
public List<Exception> initialize() {
InputStream is = null;
final ClassLoader classLoader = this.getClass().getClassLoader();
final List<Exception> exceptions = new LinkedList<Exception>();
final List<Exception> exceptions = new ArrayList<Exception>();
final String providerUriString = getProvidersUri();
if (providerUriString != null) {
try {

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2014-2021 Florian Schmaus
* Copyright 2014-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.
@ -108,6 +108,7 @@ public class AbstractError {
* @param <PE> type of the ExtensionElement.
* @return the extension, or <code>null</code> if it doesn't exist.
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
public <PE extends XmlElement> PE getExtension(String elementName, String namespace) {
return PacketUtil.extensionElementFrom(extensions, elementName, namespace);
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2020 Florian Schmaus
* Copyright © 2014-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.
@ -16,9 +16,9 @@
*/
package org.jivesoftware.smack.packet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import javax.xml.namespace.QName;
@ -31,7 +31,7 @@ public class Mechanisms implements ExtensionElement {
public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-sasl";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT);
public final List<String> mechanisms = new LinkedList<String>();
public final List<String> mechanisms = new ArrayList<String>();
public Mechanisms(String mechanism) {
mechanisms.add(mechanism);

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2015-2021 Florian Schmaus.
* Copyright 2015-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.
@ -53,9 +53,7 @@ public final class StandardExtensionElement implements XmlElement {
/**
* Constructs a new extension element with the given name and namespace and nothing else.
* <p>
* This is meant to construct extension elements used as simple flags in Stanzas.
* <p>
*
* @param name the name of the extension element.
* @param namespace the namespace of the extension element.

View file

@ -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.
@ -36,7 +36,7 @@ public interface StanzaView extends XmlLangElement {
/**
* Returns who the stanza is being sent "to", or <code>null</code> if
* the value is not set. The XMPP protocol often makes the "to"
* attribute optional, so it does not always need to be set.<p>
* attribute optional, so it does not always need to be set.
*
* @return who the stanza is being sent to, or <code>null</code> if the
* value has not been set.
@ -46,7 +46,7 @@ public interface StanzaView extends XmlLangElement {
/**
* Returns who the stanza is being sent "from" or <code>null</code> if
* the value is not set. The XMPP protocol often makes the "from"
* attribute optional, so it does not always need to be set.<p>
* attribute optional, so it does not always need to be set.
*
* @return who the stanza is being sent from, or <code>null</code> if the
* value has not been set.

View file

@ -17,9 +17,9 @@
package org.jivesoftware.smack.provider;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -39,11 +39,11 @@ import org.jivesoftware.smack.xml.XmlPullParser;
public class ProviderFileLoader implements ProviderLoader {
private static final Logger LOGGER = Logger.getLogger(ProviderFileLoader.class.getName());
private final Collection<IQProviderInfo> iqProviders = new LinkedList<IQProviderInfo>();
private final Collection<ExtensionProviderInfo> extProviders = new LinkedList<ExtensionProviderInfo>();
private final Collection<StreamFeatureProviderInfo> sfProviders = new LinkedList<StreamFeatureProviderInfo>();
private final Collection<IQProviderInfo> iqProviders = new ArrayList<IQProviderInfo>();
private final Collection<ExtensionProviderInfo> extProviders = new ArrayList<ExtensionProviderInfo>();
private final Collection<StreamFeatureProviderInfo> sfProviders = new ArrayList<StreamFeatureProviderInfo>();
private List<Exception> exceptions = new LinkedList<Exception>();
private List<Exception> exceptions = new ArrayList<Exception>();
public ProviderFileLoader(InputStream providerStream) {
this(providerStream, ProviderFileLoader.class.getClassLoader());

View file

@ -97,6 +97,7 @@ import org.jivesoftware.smack.util.XmppElementUtil;
* &lt;/extensionProvider&gt;
* &lt;/smackProviders&gt;</pre>
*
* <p>
* If multiple provider entries attempt to register to handle the same element name and namespace,
* the first entry loaded from the classpath will take precedence. Whenever a stanza extension
* is found in a packet, parsing will be passed to the correct provider. Each provider
@ -106,7 +107,8 @@ import org.jivesoftware.smack.util.XmppElementUtil;
* set the properties of th class using the values in the stanza extension sub-element. When an
* extension provider is not registered for an element name and namespace combination, Smack will
* store all top-level elements of the sub-packet in DefaultPacketExtension object and then
* attach it to the packet.<p>
* attach it to the packet.
* </p>
*
* @author Matt Tucker
*/

View file

@ -271,6 +271,7 @@ public abstract class ScramMechanism extends SASLMechanism {
return null;
}
@SuppressWarnings("MixedMutabilityReturnType")
private static Map<Character, String> parseAttributes(String string) throws SmackSaslException {
if (string.length() == 0) {
return Collections.emptyMap();

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2015-2021 Florian Schmaus
* Copyright © 2015-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.
@ -184,13 +184,14 @@ public class MultiMap<K, V> {
}
/**
* Remove the given number of values for a given key. May return less values then requested.
* Remove the given number of values for a given key. May return less values than requested.
*
* @param key the key to remove from.
* @param num the number of values to remove.
* @return a list of the removed values.
* @since 4.4.0
*/
@SuppressWarnings("MixedMutabilityReturnType")
public List<V> remove(K key, int num) {
List<V> values = map.get(key);
if (values == null) {

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software, 2019-2023 Florian Schmaus.
* Copyright 2003-2007 Jive Software, 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.
@ -25,7 +25,6 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@ -87,7 +86,7 @@ public class PacketParserUtils {
return parser;
}
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
public static <S extends Stanza> S parseStanza(String stanza) throws XmlPullParserException, SmackParsingException, IOException {
return (S) parseStanza(getParserFor(stanza), XmlEnvironment.EMPTY);
}
@ -644,7 +643,7 @@ public class PacketParserUtils {
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
String name;
final int initialDepth = parser.getDepth();
List<String> methods = new LinkedList<>();
List<String> methods = new ArrayList<>();
outerloop: while (true) {
XmlPullParser.Event eventType = parser.next();
switch (eventType) {

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2021 Florian Schmaus
* Copyright © 2014-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.
@ -32,7 +32,7 @@ public class PacketUtil {
*
* @return the extension element
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
public static <PE extends XmlElement> PE extensionElementFrom(Collection<XmlElement> collection,
String element, String namespace) {
for (XmlElement packetExtension : collection) {

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2020 Florian Schmaus.
* Copyright 2020-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.
@ -30,6 +30,7 @@ public final class Pair<F, S> {
return new Pair<>(first, second);
}
@SuppressWarnings("ReturnValueIgnored")
public static <F extends Object, S extends Object> Pair<F, S> createAndInitHashCode(F first, S second) {
Pair<F, S> pair = new Pair<>(first, second);
pair.hashCode();

View file

@ -329,7 +329,10 @@ public class StringUtils {
throw new AssertionError(e);
}
return charBuffer.flip().toString();
// Workaround for Android API not matching Java >=9 API.
// See https://issuetracker.google.com/issues/369219141
((java.nio.Buffer) charBuffer).flip();
return charBuffer.toString();
}
private static void randomString(Appendable appendable, Random random, char[] alphabet, int numRandomChars)

View file

@ -71,6 +71,7 @@ public class XmppElementUtil {
return qname;
}
@SuppressWarnings("MixedMutabilityReturnType")
public static <E extends ExtensionElement> List<E> getElementsFrom(
MultiMap<QName, XmlElement> elementMap, Class<E> extensionElementClass) {
QName qname = XmppElementUtil.getQNameFor(extensionElementClass);

View file

@ -91,6 +91,7 @@ public class DummyConnection extends AbstractXMPPConnection {
user = getUserJid();
}
@SuppressWarnings("JavaUtilDate")
@Override
protected void connectInternal() {
connected = true;
@ -162,6 +163,7 @@ public class DummyConnection extends AbstractXMPPConnection {
* @param <P> the top level stream element class.
* @return a sent packet.
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
public <P extends TopLevelStreamElement> P getSentPacket() {
return getSentPacket(5 * 60);
}
@ -176,7 +178,7 @@ public class DummyConnection extends AbstractXMPPConnection {
* @param <P> the top level stream element class.
* @return a sent packet.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
public <P extends TopLevelStreamElement> P getSentPacket(int wait) {
try {
return (P) queue.poll(wait, TimeUnit.SECONDS);