1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-10-18 12:15:58 +02:00
Commit graph

183 commits

Author SHA1 Message Date
Florian Schmaus
1e5d34eacf 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
2024-09-25 12:08:50 +02:00
Florian Schmaus
4a101e2c99 Delete APIs scheduled for removal with Smack 4.5 2024-09-14 21:34:47 +02:00
Guus der Kinderen
c85bcadd81 Fixes spelling (includes one API change)
Mostly benign changes. Added one new method to replace a method with a spelling mistake in its name. Kept the old method, marked as 'deprecated'.
2024-09-11 20:03:43 +02:00
Florian Schmaus
4c60986795 Merge branch '4.4' 2024-04-02 18:48:36 +02:00
Florian Schmaus
6918663760 [roster] suppress "roster not loaded while processing presence" if self-presence
Fixes SMACK-941.
2024-04-02 15:11:47 +02:00
Guus der Kinderen
3a84a1ff47 s/ the the / the /g 2023-02-03 20:53:14 +01:00
Florian Schmaus
c9a9982cef Migrate markdown documentation to javadoc
While markdown is easier to write, Smack's markdown documentation was
never tightly coupled with the source. For example, the markdown
documentation never provided links to the actual Java classes and
methods. This poses the risk that the documentation and the code
diverge over time. Furthermore, javadoc is constantly improving (for
example @snippet annotations) and I expect that one will be able to
write javadoc in markdown.

Fixes SMACK-928.
2023-02-03 09:50:35 +01:00
Ingo Bauersachs
4efa707028 Replace legacy IQProvider with IqProvider 2022-04-02 16:02:46 +02:00
Danny Baumann
aafc24a966 Conditionally reduce severity of roster reload error logging
If the roster feature is not supported by the server, there's no need to
log this at SEVERE log level.
2022-02-15 12:21:27 +01:00
Florian Schmaus
aab48570c9 Call XMPPConnection.sendIqRequestAndWaitForResponse(IQ) where possible
Refactored using

find . -type f -name "*.java" |\
	 xargs sed -i -E |\
		's/\.createStanzaCollectorAndSend\((\w+)\)\.nextResultOrThrow\(\);/.sendIqRequestAndWaitForResponse(\1);/'

and some manual refactoring.
2021-05-12 10:12:40 +02:00
Florian Schmaus
5493a22e44 Merge branch '4.4' 2021-04-18 17:25:14 +02:00
Florian Schmaus
961882ff7f Add more QNAME fields to extension element classes 2021-04-18 17:23:34 +02:00
Florian Schmaus
fbddd074bc [gradle] Do not use deprecated 'compile' directive 2021-04-14 20:30:51 +02:00
Florian Schmaus
a7b3303f3e Bump ErrorProne to 2.5.1 and refactor Providers a bit
This also resulted in a refactoring of the Providers and parsing
Exceptions. NumberFormatException and ParseException can now be thrown
directly, the wrapping in a SmackParsingException is down at a higher
layer, i.e. in AbstractProvider.
2021-01-29 09:26:15 +01:00
Florian Schmaus
65d7c1c1b8 [im] Update DirectoryRosterStore TODO note regarding Android API 26. 2021-01-06 13:48:49 +01:00
Florian Schmaus
40aa9e87b7 [im] DirectoryRosterStore.readEntry() should also catch IllegalArgumentException
Fixes SMACK-897.
2021-01-06 13:48:03 +01:00
Florian Schmaus
3f9ca68134 Delete TypedCloneable 2020-06-14 17:38:51 +02:00
Florian Schmaus
d65f2c932e Bump Error Prone version to 2.3.4 and fix new bug patterns 2020-05-24 21:10:01 +02:00
Florian Schmaus
ebe5c49e92 [checkstyle] Tighten JavadocMethod checkstyle rule 2020-05-23 22:43:29 +02:00
Florian Schmaus
ab2d3a2b79 [core] Deprecate AbstractConnectionListener 2020-05-13 22:14:43 +02:00
Florian Schmaus
b5f9d4d7a3 Introduce test fixtures
This also removes the powermock dependency. Although powermock is a
fine library, it currently prevents dropping Junit4. And since we only
use the Whitebox API of powermock, this simply replaced powermock's
Whitebox with our own.
2020-04-11 22:05:36 +02:00
Florian Schmaus
14c351397d Implement message stanza <thread/> and <subject/> as ExtensionElement
Fixes SMACK-852.
2020-04-05 18:58:13 +02:00
3fb4438566 Reorder smack-extensions providers xml
Fix rfc number
2020-04-04 13:03:35 +02:00
Florian Schmaus
eb4c2c5572 s/occured/occurred/ 2019-10-30 12:02:36 +01:00
Florian Schmaus
5db6191110 Introduce StanzaBuilder
As first step to immutable Stanza types.
2019-10-25 21:41:55 +02:00
Florian Schmaus
2f667f95a8 gradle: Remove archives configuration
and FileTestUtil in favor of commons-io. This is required because
Eclipse won't put src/test code into the classpath of src/main
code (even though gradle was configured with an according
dependency).
2019-09-16 00:04:47 +02:00
Florian Schmaus
65576cf3c2 Rework XML Element hierarchy and XmlStringBuilder
- Reduce the amount of types that are subtypes of NamedElement. See
javadoc of NamedElement for rationale.
- Work more with XmlEnvironment in XmlStringBuilder.
- Some minor changes to XmlStringBuilder API.
2019-09-07 18:17:08 +02:00
Florian Schmaus
1a3067c89b Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
Florian Schmaus
f863bd222c Merge branch '4.3' 2019-08-22 11:52:41 +02:00
Florian Schmaus
d40b16b5a7 Fix log message format in Roster: s/{}/{0}/
The MessageFormat used by the JUL Logger requires integers between the
curly brackets (unlike SLF4J).
2019-08-22 10:55:33 +02:00
Florian Schmaus
4ca2c7cc69 Enable MissingJavadocPackage and UnnecessaryParentheses checkstyle checks 2019-07-24 09:18:39 +02:00
Florian Schmaus
91ec6cc955 Javadoc changes for Java 11 compatibility 2019-07-19 23:05:46 +02:00
Florian Schmaus
fa0c16d75c Introduce EqualsUtil and HashCode.(Builder|Cache) 2019-06-12 14:51:17 +02:00
Florian Schmaus
619b8e6f4a Add secure(OnlineAttackSafe|Unique|OfflineAttackSafe)RandomString()
and replace usages of java.util.UUID in Smack with
secureUniqueRandomString() because it uses a thread-local secure random
number generator.
2019-06-02 20:08:03 +02:00
Florian Schmaus
f7762c5db7 Add "whitespace after comma" checkstyle rule 2019-05-17 21:56:46 +02:00
Florian Schmaus
68d7d738b6 Remove all tabs and add checkstyle rule that enforces no-tabs
Fixes SMACK-866.
2019-05-07 21:24:00 +02:00
Florian Schmaus
4133eb175c Replace XPP3 by XmlPullParser interface wrapping StAX and XPP3
Introducing Smack's own XmlPullParser interface which tries to stay as
compatible as possible to XPP3. The interface is used to either wrap
StAX's XMLStreamReader if Smack is used on Java SE, and XPP3's
XmlPullParser if Smack is used on on Android.

Fixes SMACK-591.

Also introduce JUnit 5 and non-strict javadoc projects.
2019-05-06 22:10:50 +02:00
Florian Schmaus
af0fb7543c
Merge pull request #309 from vanitasvitae/rosterListenerDoc
Add missing Roster documentation
2019-04-06 15:19:59 +02:00
af88227919
Add missing Roster documentation 2019-04-06 02:36:32 +02:00
Florian Schmaus
d10319f1a0 Merge branch '4.3' 2019-04-05 10:22:12 +02:00
Florian Schmaus
9be498c440 Fix NPE in Roster's presence listeners if 'from' is not set
The NPE is caused by an inbound presence stanza without the 'from'
attribute set. The stacktrace of the NPE is:

FATAL EXCEPTION: Smack Cached Executor
Process: de.fhg.ivi.senetz.mobile.android.mbk.debug, PID: 13365
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference
    at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:944)
    at org.jivesoftware.smack.roster.Roster.getPresencesInternal(Roster.java:374)
    at org.jivesoftware.smack.roster.Roster.getOrCreatePresencesInternal(Roster.java:388)
    at org.jivesoftware.smack.roster.Roster.access$1100(Roster.java:94)
    at org.jivesoftware.smack.roster.Roster$PresencePacketListener$1.run(Roster.java:1519)
    at org.jivesoftware.smack.AsyncButOrdered$Handler.run(AsyncButOrdered.java:121)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:764)

Thanks to Marcel Heckel for reporting this.

Fixes SMACK-861.
2019-04-02 14:28:41 +02:00
Florian Schmaus
9c4e5d0330 Add Roster.createItem() and Roster.createItemAndRequestSubscription()
and deprecate createEntry().

createEntry() would also send a subscription request which may is
suprising given that you can also create an roster item without having
to send a subscription request out.

This also fixes a bug in
LowLevelRosterIntegrationTest.testPresenceEventListenersOffline()
where createEntry() was used, which would also trigger a presence
subscription request which in turn made the test fail if the
SubscribeListener of ensureSubscribedTo() was not yet set
up. So the test would fail depending on the timing.
2019-03-16 21:23:45 +01:00
Florian Schmaus
8df69bd3ce Use XmlEnvironment in parsing/provider subsystem 2019-02-15 23:21:30 +01:00
Florian Schmaus
083dac8b83 Rework exceptions in the parsing / provider subsystem 2019-02-05 13:18:03 +01:00
Florian Schmaus
fee3ed81ca Introduce XmlEnvironment 2019-02-05 13:18:03 +01:00
Florian Schmaus
e98d42790a SmackReactor/NIO, Java8/Android19, Pretty print XML, FSM connections
This commit adds
- SmackReactor / NIO
- a framework for finite state machine connections
- support for Java 8
- pretty printed XML debug output

It also
- reworks the integration test framework
- raises the minimum Android API level to 19
- introduces XmppNioTcpConnection

Furthermore fixes SMACK-801 (at least partly). Java 8 language
features are available, but not all runtime library methods. For that
we would need to raise the Android API level to 24 or higher.
2019-02-05 13:18:03 +01:00
Florian Schmaus
b7ea226c56 Bump "Error Prone" to 2.3.2
and gradle-errorprone-plugin to 0.6.
2018-10-31 16:06:31 +01:00
Florian Schmaus
ab120691cb Smack 4.3.1
-----BEGIN PGP SIGNATURE-----
 
 iQGTBAABCgB9FiEEl3UFnzoh3OFr5PuuIjmn6PWFIFIFAlvDIBdfFIAAAAAALgAo
 aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDk3
 NzUwNTlGM0EyMURDRTE2QkU0RkJBRTIyMzlBN0U4RjU4NTIwNTIACgkQIjmn6PWF
 IFKObAgApvEwstvSXhgzlrA46DM6fXezbPEnO1rh8rCPJEAsmfBSnyINSuuhelzw
 zN8L7GAU0jDeuDivxA12vQx5QB8wuCHKgc5pXDKNRi9eUdsyDUMKswcbMMAJWDvq
 I3bm7TOC1D9ZWmfhGmqfulrsVD1Q0wh+P2A1/CWVR5ZZUB5S4fESFZUrnCfJmeXe
 f+INXUiui3otAF6nPxKm782rSfHWvA32i4Obnagh3oPX/c9R7Ftb78Wukrsbaqfg
 +a5iTlBJXLG75/Yozq+JqmWlUvEKv7le0vkF5fF+oc76H4p1U1wqQyIMei/Pwaer
 H/SyMqLPzCiwpUHiunpWD13e5kkeLw==
 =47on
 -----END PGP SIGNATURE-----

Merge tag '4.3.1'

Smack 4.3.1
2018-10-14 14:31:31 +02:00
spslinger
1e21ab763c
Fix getPresence ConcurrentModificationException
Fix for SMACK-841

Since Smack 4.2.4, the getPresencesInternal method in the Roster class
can return a LruCache object, which is a LinkedHashMap with access
order. This means that any access using get or getOrDefault will be a
modification of the Map. If you loop over the keySet of the Map and
there are more than one, the second call to get will throw a
ConcurrentModificationException!

Since the keys are only used here to obtain the corresponding
values, the simplest solution is to just loop over the values instead.
2018-10-11 12:29:32 +02:00
Florian Schmaus
24267c532d Improve style of RosterStore 2018-08-21 13:33:45 +02:00