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

979 commits

Author SHA1 Message Date
Florian Schmaus
1d498efd46 [muc] Add support for muc#roomconfig_enablelogging to MucConfigFormManager 2024-05-20 22:17:38 +02:00
Florian Schmaus
9447030cd4 [muc] Do not invoke userHasLeft() on nickname change
When the incoming unavailable presence is signalling a nickname
change (303), then do not invoke userHasLeft(), because the user
actually does not leave but instead just changes its nickname.

Note that this would also have had fixed SMACK-942, as it would
resolve the deadlock. However, using a dedicated lock for
changeNickname() still seems sensible, and if its just to avoid a bit
of lock contention.

What this also fixes is that a MultiUserChat does no longer invoke its
listener-based callbacks after a nickname change, as previously, after
a nickname change, the userHasLeft() would have been invoked, which
tears down the listeners. This issue was found with
MultiUserChatOccupantIntegrationTest.mucChangeNicknameInformationTest().
2024-05-20 21:45:47 +02:00
Florian Schmaus
c34c9bdb62 [muc] Fix MultiUserChat.changeNickname(Resourcepart)
Using this method used to result in a deadlock, as shown by these two threads

"main" #1 prio=5 os_prio=0 cpu=926.39ms elapsed=21.00s tid=0x00007f463802c800 nid=0x5a691 in Object.wait()  [0x00007f463f323000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
	at java.lang.Object.wait(java.base@11.0.23/Native Method)
	- waiting on <0x0000000622e82fd8> (a org.jivesoftware.smack.StanzaCollector)
	at org.jivesoftware.smack.StanzaCollector.nextResult(StanzaCollector.java:206)
	- waiting to re-lock in wait() <0x0000000622e82fd8> (a org.jivesoftware.smack.StanzaCollector)
	at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:270)
	at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:228)
	at org.jivesoftware.smackx.muc.MultiUserChat.changeNickname(MultiUserChat.java:1314)
	- locked <0x0000000622e19700> (a org.jivesoftware.smackx.muc.MultiUserChat)
	at org.jivesoftware.smackx.muc.MultiUserChatOccupantIntegrationTest.mucChangeNicknameInformationTest(MultiUserChatOccupantIntegrationTest.java:981)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@11.0.23/Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@11.0.23/NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@11.0.23/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@11.0.23/Method.java:566)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.lambda$runTests$0(SmackIntegrationTestFramework.java:476)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework$$Lambda$141/0x000000084026e040.execute(Unknown Source)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.runConcreteTest(SmackIntegrationTestFramework.java:551)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework$PreparedTest.run(SmackIntegrationTestFramework.java:759)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.runTests(SmackIntegrationTestFramework.java:539)
	at org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.run(SmackIntegrationTestFramework.java:277)
	- locked <0x000000062d191318> (a org.igniterealtime.smack.inttest.SmackIntegrationTestFramework)
	at
	org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.main(SmackIntegrationTestFramework.java:115)

"Smack Cached Executor" #19 daemon prio=5 os_prio=0 cpu=7.85ms elapsed=20.48s tid=0x00007f4638a42800 nid=0x5a6b2 waiting for monitor entry  [0x00007f46023fe000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at org.jivesoftware.smackx.muc.MultiUserChat.userHasLeft(MultiUserChat.java:2281)
	- waiting to lock <0x0000000622e19700> (a org.jivesoftware.smackx.muc.MultiUserChat)
	at org.jivesoftware.smackx.muc.MultiUserChat.access$800(MultiUserChat.java:117)
	at org.jivesoftware.smackx.muc.MultiUserChat$3.processStanza(MultiUserChat.java:263)
	at org.jivesoftware.smack.AbstractXMPPConnection.lambda$invokeStanzaCollectorsAndNotifyRecvListeners$8(AbstractXMPPConnection.java:1654)
	at org.jivesoftware.smack.AbstractXMPPConnection$$Lambda$127/0x000000084022f440.run(Unknown Source)
	at org.jivesoftware.smack.AbstractXMPPConnection$10.run(AbstractXMPPConnection.java:2213)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11.0.23/ThreadPoolExecutor.java:1128)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@11.0.23/ThreadPoolExecutor.java:628)
	at java.lang.Thread.run(java.base@11.0.23/Thread.java:829)

The changeNickname() method was synchronized and is userHasLeft(),
this caused a deadlock since changeNickname() awaits the presence that
is send as result of the nickname change. But this presence is also
processed in a listener which invokes userHasLeft(). However, this
invocation blocks as userHasLeft() is waiting on the montior currently
hold by the thread invoking changeNickname().

To fix this, we change changeNickname() to not take the MultiUserChat
monitor, but instead use a dedicate lock.

Fixes SMACK-942.
2024-05-20 21:45:34 +02:00
Florian Schmaus
c4ce6b4707 [muc] Add support for muc#roomconfig_roomname in MucConfigFormManager 2024-05-20 15:10:56 +02:00
Dan Caseley
855f01e6b2 [sinttest] Additional tests for s7 of XEP-0045 2024-04-30 09:44:58 +02:00
Florian Schmaus
4c60986795 Merge branch '4.4' 2024-04-02 18:48:36 +02:00
Florian Schmaus
a39e5baa74 [socks5] Ignore zone IDs of internet addresses
Fixes SMACK-940.
2024-02-09 14:15:09 +01:00
Florian Schmaus
e504bc23cf [extensions] Improve IAE message thrown by FormFieldRegistry 2024-01-18 17:31:36 +01:00
Florian Schmaus
8b9a9e0f3e [xdata] Fix NPE in FillableForm
Calling write() in FillableForm's constructor causes a NPE because
write() makes use of requiredFields which has not been set at this
time. Furthermore, write() makes use of missingRequiredFields, which
is also populated in that loop. Therefore, we have to delay the
invocation of write() until requiredFields got set.

Thanks to Dan Caseley for reporting this.

Reported-by: Dan Caseley <dan@caseley.me.uk>
2024-01-11 09:12:14 +01:00
Florian Schmaus
643d85c556 [xdata] Fix NPE in FillableForm
Calling write() in FillableForm's constructor causes a NPE because
write() makes use of requiredFields which has not been set at this
time. Furthermore, write() makes use of missingRequiredFields, which
is also populated in that loop. Therefore, we have to delay the
invocation of write() until requiredFields got set.

Thanks to Dan Caseley for reporting this.

Reported-by: Dan Caseley <dan@caseley.me.uk>
2024-01-10 10:43:00 +01:00
Florian Schmaus
1ad394f256 [urldata] Follow-up on initial merge of XEP-0103/0104 support
This is a follow-up on 198c51356d ("Add initial support for XEP-0103
and XEP-0104: URL Address Information"), which
1. adds the entries to the support XEPs table
2. registers the provider
3. renames the package from url_address_information to urldata (aka.
   the shortname of XEP-0130).
2023-12-16 13:50:30 +01:00
Florian Schmaus
8425671b31 Merge commit '198c51356dd81a1521bba46d2d30e505d47062d1' 2023-12-16 13:25:41 +01:00
Florian Schmaus
90b8eee0d1 [extensions] Drop newlines in test string within GroupChatInvitationElementTest 2023-12-07 15:18:04 +01:00
664a141190 [extensions] Improved Support for Direct MUC Invitations (XEP-0249)
[flow: rebase of paul's initial submission which required adjustments]

Co-authored-by: Florian Schmaus <flo@geekplace.eu>
2023-12-07 15:01:44 +01:00
Florian Schmaus
2337a446a5 Re-work ad-hoc command (XEP-0050) implementation
Fixes SMACK-933.
2023-12-06 12:40:53 +01:00
Florian Schmaus
b5b4418406 Merge branch '4.4' 2023-11-25 17:36:15 +01:00
Florian Schmaus
ccfbf9f346 [caps] Use a synchronous listener for incoming presence stanzas
Fixes SMACK-937.
2023-11-24 12:15:32 +01:00
Florian Schmaus
19b20fefec
Merge pull request #537 from MF1-MS/mf1-ms/use_xmpp_connection_as_local_socks5_address
Use XMPP connection as local socks5 address
2023-04-26 11:35:04 +00: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
Martin Fidczuk
9e9c233468
Add partial support for XEP-0249 Direct MUC Invitations.
Exposes a method for a MUC to invite a user to the room, and adds a listener to the MultiUserChat listener to inform users of direct invitations they have received.

Fixes SMACK-932.
2023-04-24 10:47:06 +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
cmeng-git
ef0fc01505 Rename ELEMENT 'candidate-activated' to 'activated' per XEP-0260
Fixes SMACK-930.
2023-03-17 17:48:15 +01:00
Florian Schmaus
d93fbacc35
Merge pull request #546 from bgrozev/fix-npe-when-missing-x
Add null check for mucUser.
2023-03-17 17:45:43 +01:00
Florian Schmaus
d565354dea [jingle] Ignore IP Zone ID is transport candidates
Fixes SMACK-929.
2023-03-17 17:40:15 +01:00
Boris Grozev
6da9773bbf Add null check for mucUser.
XEP-0045 requires "unavailable" presence to contain extended presence, but Smack shouldn't throw an exception if it doesn't.
2023-02-17 11:40:04 -06: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
875fb7fcfd Merge branch '4.4' 2022-09-02 16:17:12 +02:00
Florian Schmaus
9486fd6176 [muc] Remove stale comment from MultiUserChat.userHashLeft()
Set started with Smack 4.4 to set myRoomJid to null, introduced by
ab2822be3e ("muc: also set myRoomJid to null if we have left the
room"), however the code comment still states that we "do not reset
nickname here" (and myRoomJid contains the nickname as its
resourcepart).

Reported-by: Damian Minkov <damencho@jitsi.org>
2022-09-02 16:13:49 +02:00
Florian Schmaus
5455cfb3d2 Merge branch '4.4' 2022-08-30 21:54:49 +02:00
Andrey Volykhin
fbd5761296 [muc] Fix removal of the MUC's main presence interceptor
On dinamically remove the last existed presence interceptor
we also should to remove the MUC's main presence interceptor from the connection.

Fixes: 60fee7b ("[muc] Fix Presence interceptors")
2022-08-30 11:57:23 +00:00
Florian Schmaus
9eee3b8d76 [muc] Fix GroupChatInviation's constructor
Fixes: 5e1cd62021 ("[muc] Null-check GroupChatInviation's 'roomAddress' argument")
2022-08-07 17:03:05 +02:00
Florian Schmaus
5e1cd62021 [muc] Null-check GroupChatInviation's 'roomAddress' argument 2022-08-03 17:39:30 +02:00
Florian Schmaus
711d7d92bd [muc] Use EntityBareJid instead of String in GroupChatInvitation
Also factor provider in extra file.
2022-08-01 21:54:37 +02:00
Florian Schmaus
70d0843dd8 Merge branch '4.4' 2022-05-26 18:13:29 +02:00
Florian Schmaus
69e81b748e [disco] Only perform entity capabilities work if there are any listeners 2022-05-26 18:03:36 +02:00
Florian Schmaus
5b6dd8e3f7 [disco] Fix memory leak in ServiceDiscoveryManager
The lambda we schedule in 25ms captures a strong reference to the
XMPPConnection. However the lambda is part of the scheduled action,
which we save in the renewEntityCapsScheduledAction field. This causes
a memory leak, since the ServiceDiscoveryManager now holds a strong
reference to its XMPPConnection.

Fix this by obtaining the strong reference to the XMPPConnection, if
one still exists, within the lambda.

Fixes SMACK-926.

Reported-by: Damian Minkov <damencho@jitsi.org>
2022-05-26 15:39:41 +02:00
Florian Schmaus
c84ac4b2ae Merge branch '4.4' 2022-05-23 12:32:29 +02:00
Florian Schmaus
60fee7b318 [muc] Fix Presence interceptors
Presence interceptors where hooked into stanza sending listeners,
which are called *after* the stanza has been put on the wire, i.e., to
late for interceptors that any modifications, they may perform, to
take effect.

Fixes SMACK-925.

We now also dynamically add the MUC's main presence interceptor to the
connection.

Reported-by: Damian Minkov <damencho@jitsi.org>
2022-05-22 10:51:45 +02:00
Ingo Bauersachs
4efa707028 Replace legacy IQProvider with IqProvider 2022-04-02 16:02:46 +02:00
Florian Schmaus
78ffcae880 Merge branch '4.4' 2022-03-06 21:46:10 +01:00
Florian Schmaus
95ff591c14 [xdata] Only emit warning about unregistered fields once per field 2022-03-06 21:44:33 +01:00
Florian Schmaus
a15110694a Merge branch '4.4' 2022-02-18 21:30:42 +01:00
cmeng-git
4d026d8ae8 [jingle] Add element and text to JingleReason's XML 2022-02-18 21:29:32 +01:00
Florian Schmaus
ad9867ebdf Merge branch '4.4' 2022-02-03 08:43:32 +01:00
Florian Schmaus
7fad14ac0c [jingle] Improve Jingle <reason/> support
Fixes SMACK-922.
2022-02-02 12:10:53 +01:00
Florian Schmaus
5f75d141ff Merge branch '4.4' 2021-12-27 21:25:24 +01:00
Florian Schmaus
5c46451cd2 [xdata] Add BooleanFormField.getValueAsBooleanOrNull()
This method is meant to provide 'raw' access to what has been sent
over the wire. It is assumed to be not of much use in the typically
case, but provided for completeness.
2021-12-27 21:24:19 +01:00
Florian Schmaus
940d7bf02a [xdata] Adjust behavior of BooleanFormField.getValueAsBoolean()
According to XEP-0004 § 3.3, the default value of a boolean form field
is 'false'. And since users are typically interested in getting the
value, and not potentially 'null' as result, we adjust the behavior of
the getValueAsBoolean() method consider the default value.
2021-12-27 21:17:57 +01:00