1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-15 08:42:05 +01:00
Commit graph

1137 commits

Author SHA1 Message Date
Florian Schmaus
02d8f53246 [core] Increase resilience against faulty parser implementions
If one of the parser throws a NullPointerException or
NumberFormatException, then this should not lead to a disconnect due
to an unhandled exception. Instead wrap those in an exception that is
handled by the parsing exception callback and ask the user to fill a
bug report for those faulty parsers.

We may adjust the list of exceptions that are wrapped in the future.
2024-10-15 12:50:33 +02:00
Florian Schmaus
beacb5eb8e [build] Bump error prone from 2.9.0 to 2.32.0 2024-09-25 21:32:17 +02:00
Florian Schmaus
2eddf1949a [github ci] Build also with Java 21 2024-09-25 15:15:04 +02:00
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
1c1f57d9ff [core] Refine javadoc for ConnectionConfiguration.getLanguage() 2024-09-15 19:10:14 +02:00
Florian Schmaus
49379afd3f [core] Correctly handle BCP 42 language tag creation from Locale for xml:lang
Fixes SMACK-952
2024-09-15 19:09:45 +02:00
Florian Schmaus
4a101e2c99 Delete APIs scheduled for removal with Smack 4.5 2024-09-14 21:34:47 +02:00
Florian Schmaus
5633d0e6c2
Merge pull request #623 from hamed-sb/master
[core] fix toXml for UnparsedIQ
2024-09-12 11:32:28 +00: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
hamed-sb
609781b5ad [core] fix toXml for UnparsedIQ 2024-09-05 12:50:57 +03:30
Florian Schmaus
0bb3bf292c [core] Add NotFilter.of(Class<E extends ExtensionElement>) 2024-06-22 20:01:35 +02:00
Florian Schmaus
4ce926bd63 [core] Use StanzaView as StanzaIdFilter constructor parameter type
Instead of Stanza, use StanzaView as constructor parameter type of
StanzaIdFilter. Even though StanzaView also includes builders, the
Stanza ID is even immutable in builders.
2024-06-01 00:16:56 +02:00
Florian Schmaus
1836537c42 [core] Add unit test for IQ parsing
Motivated by
https://discourse.igniterealtime.org/t/question-about-tigase-server-8-3-1-and-smack-4-4-7/93796/
2024-05-20 15:18:37 +02:00
Florian Schmaus
726dbc0d27 [core] Add XmlStringBuilder.jidAttribute(Jid) and optJidAttribute(Jid) 2023-12-07 15:01:43 +01:00
Florian Schmaus
f74f47f6d4 Merge branch '4.4' 2023-12-07 11:22:43 +01:00
Florian Schmaus
390f6f0fa7 [core] Fix busy-loop in SmackReactor
Fixes SMACK-938.
2023-12-07 11:22:38 +01:00
Florian Schmaus
9acee05e5e [core] Improve how the selected keys are copied in SmackReactor 2023-12-07 11:20:37 +01:00
Florian Schmaus
844ebbf4c5 [core] Add milliseconds to ConsoleDebugger's timestamp 2023-12-06 20:55:37 +01:00
Florian Schmaus
dac06b04c3 [core] Add XmlStringBuilder.setAppendApproach() 2023-11-28 11:04:24 +01:00
Florian Schmaus
5a78534443 [core] Mark LazyStringBuilder's String cache as transient 2023-11-26 21:35:19 +01:00
Florian Schmaus
6322f4f826 [core] Add global option to flatten when appending in XmlStringBuilder
For certain use cases, this provides a performance improvement,
probably due better cache locality. However, it comes with the cost of
additional memory consumption.

This was initially suggested by Boris Grozev, who also reported a
significant performance problem of
XmlStringBuilder/LazyStringBuilder. However, the main cause of the
performance probelm was the missing caching of LazyStringBuilder. The
length of the lazy string is now cached by LazyStringBuidler since
70e48300a6 ("[core] Cache length in LazyStringBuilder"), which
accounts for large performance improvement. A significantly smaller
improvement is achieved by this commit and setting
XmlStringBuilder.FLAT_APPEND to 'true'.

Suggested-by: Boris Grozev <boris@jitsi.org>
2023-11-26 21:34:13 +01:00
Florian Schmaus
70e48300a6 [core] Cache length in LazyStringBuilder 2023-11-26 21:24:17 +01:00
Florian Schmaus
b5b4418406 Merge branch '4.4' 2023-11-25 17:36:15 +01:00
Florian Schmaus
a270542397 [core] Improve javadoc for listeners
With 92f253cc74 ("[core] Replace
AbstractXMPPConnection.inOrderListeners") we changes the behavior of
listeners. This commit documents the expectations to the user.
2023-11-24 12:59:04 +01:00
Florian Schmaus
f593b6d0a0 [core] Whitespace fix in XMPPConnection's javadoc 2023-11-24 12:18:19 +01:00
Martin Fidczuk
ffd027cc7d
Use XMPP connection as local SOCKS5 address
The default local address is often just "the first address found in the list of addresses read from the OS" and this might mean an internal IP address that cannot reach external servers. So wherever possible use the same IP address being used to connect to the XMPP server because this local address has a better chance of being suitable.

This MR adds the above behaviour, and two UTs to test that we use the local XMPP connection IP when connected, and the previous behaviour when not.
2023-04-26 10:00:23 +01:00
Florian Schmaus
f78eade4da Merge branch '4.4' 2023-03-17 18:20:20 +01:00
Florian Schmaus
bf3a27df9a [core] Fix ErrorIQ not showing potential original IQ child
Also delete StanzaIdTest since the test was fundamentally weak and
flawed. It does not work anyway, since TestIQ has a fixed stanza ID.

Fixes SMACK-931.
2023-03-17 18:03:57 +01:00
Florian Schmaus
dee34b5efc [core] Add InternetAddress.fromIgnoringZoneId(String) 2023-02-12 16:06:53 +01: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
Florian Schmaus
92f253cc74 [core] Replace AbstractXMPPConnection.inOrderListeners
Using AsyncButOrdered for the receive listeners means that a listener
may not have been yet run once
invokeStanzaCollectorsAndNotifyRecvListeners() returnes. This can lead
to deadlocks as reported by Boris Grozev [1].

Fixes SMACK-927.

1: https://discourse.igniterealtime.org/t/thread-stuck-in-multiuserchat-enter-forever/92090
2022-10-05 11:28:48 +02:00
Florian Schmaus
e87da18495 Bump Bouncy Castle to 1.71 2022-08-07 16:59:47 +02:00
Florian Schmaus
167af86f79 [core] Make ExtensionElementFilter's constructor public 2022-08-07 16:55:41 +02:00
Florian Schmaus
c77948bb91 Add non-blocking send 2022-08-03 16:57:57 +02:00
Florian Schmaus
6be3eb194a Merge branch '4.4' 2022-06-07 08:41:46 +02:00
Florian Schmaus
66370c7ef5 [core] Add SmackConfiguration.TRUELY_ASYNC_SENDS
This option is meant a quick and dirty hack until
XMPPConnection.sendStanza() throws a dedicated Exception in case the
connection's outgoing queue is full.
2022-06-06 09:52:57 +02:00
Florian Schmaus
e51bfb1dbe Merge branch '4.4' 2022-05-18 21:46:19 +02:00
Florian Schmaus
00bcbff5ee [core] Add ConnectionConfiguration.getHostString() 2022-05-18 21:45:00 +02:00
Florian Schmaus
70abd8a182 Merge branch '4.4' 2022-04-30 15:16:24 +02:00
Florian Schmaus
881ebe731d [core] Fix typo in javadoc 2022-04-30 15:15:51 +02:00
Florian Schmaus
1f5326abb2 [core] Inline waitForConditionOrConnectionException
Using any of the two methods is error prone, see 0e0c0a4093 ("[tcp]
Fix handling in connection exceptions when resuming a stream"), as one
can easily forget to check for connection exceptions after it
returned. There are also no longer any call sites of those methods.

Let's inline both variants of this method.
2022-04-30 15:15:42 +02:00
Ingo Bauersachs
4efa707028 Replace legacy IQProvider with IqProvider 2022-04-02 16:02:46 +02:00
Florian Schmaus
a15110694a Merge branch '4.4' 2022-02-18 21:30:42 +01:00
Florian Schmaus
ba2e36dbc3 [core] Deprecate some SSLContext config options and add KeyManager option
Smack historically provided fine-grained options for the
SSLContext. This is however not flexible enough, as an option to
specifiy the KeyManager(s) was missing.

This deprecated the options for keystore path, keystore type, and
PKCS#11 library, in favor of an option to set the KeyManager, which
could be aware of the keystore path and type, and the PKCS#11
library. At some point, Smack may provide some high-level methods to
create a KeyManager from provided keystore path, keytsore type and
PKCS#11 library.
2022-02-17 12:17:54 +01:00
Florian Schmaus
4a83d2957e Merge branch '4.4' 2022-02-06 17:48:08 +01:00
Boris Grozev
67a5c3a41a [core] Correctly handle due time of '0' in SmackReactor
Scheduled actions that are due in 0 milliseconds are due
immediately. Otherwise we would invoke select() with 0.

Fixes SMACK-923.
2022-02-06 17:38:50 +01:00
Florian Schmaus
ad9867ebdf Merge branch '4.4' 2022-02-03 08:43:32 +01:00
Florian Schmaus
5cd7a6c60e
Merge pull request #509 from Flowdalic/jingle-reason-extension-element
Jingle reason extension element
2022-02-03 07:58:29 +01:00
Florian Schmaus
3ff553549a [SmackFuture] Invoke the callbacks at most once
Previously, if a SmackFuture both was successful and unsuccessful, it
was possible that the onSuccess() callback was invoked twice.

Reported-by: Boris Grozev <boris@jitsi.org>
2022-02-02 20:47:31 +01:00