From 4ab45b9660544d5373b623dadc6d794a84a25615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Wed, 11 Dec 2024 06:37:17 +0100 Subject: [PATCH] fixup! Fix "removePeerConnection" not being thread-safe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- .../talk/webrtc/PeerConnectionWrapperTest.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionWrapperTest.kt b/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionWrapperTest.kt index ade64341dbd..f49c25ec095 100644 --- a/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionWrapperTest.kt +++ b/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionWrapperTest.kt @@ -533,7 +533,7 @@ class PeerConnectionWrapperTest { // Add data channels with duplicated labels (from the second data channel and onwards) to test that // they are correctly disposed also in that case (which should not happen anyway, but just in case). Mockito.`when`(mockedRandomIdDataChannels[j].label()) - .thenAnswer(ReturnValueOrThrowIfDisposed("random-id-" + ((j+1) / 2))) + .thenAnswer(ReturnValueOrThrowIfDisposed("random-id-" + ((j + 1) / 2))) Mockito.`when`(mockedRandomIdDataChannels[j].state()) .thenAnswer(ReturnValueOrThrowIfDisposed(DataChannel.State.OPEN)) @@ -544,7 +544,8 @@ class PeerConnectionWrapperTest { doAnswer { invocation -> if (Mockito.mockingDetails(invocation.mock).invocations.find { it!!.method.name === "dispose" - } !== null) { + } !== null + ) { throw IllegalStateException("DataChannel has been disposed") } @@ -574,7 +575,7 @@ class PeerConnectionWrapperTest { val removePeerConnectionThread = thread { try { peerConnectionWrapper!!.removePeerConnection() - } catch(e: Exception) { + } catch (e: Exception) { exceptionRemovePeerConnection = e } } @@ -644,7 +645,7 @@ class PeerConnectionWrapperTest { for (j in 0.. = ArgumentCaptor.forClass(DataChannel.Observer::class.java) - doNothing().`when`(mockedStatusDataChannel).registerObserver(statusDataChannelObserverArgumentCaptor.capture()) + doNothing().`when`(mockedStatusDataChannel) + .registerObserver(statusDataChannelObserverArgumentCaptor.capture()) peerConnectionWrapper = PeerConnectionWrapper( mockedPeerConnectionFactory,