Skip to content

Commit

Permalink
Fix RetryRemoteAction double callback (#262)
Browse files Browse the repository at this point in the history
* Fix RetryRemoteAction double callback

* PubNub SDK v9.2.3 release.

---------

Co-authored-by: PubNub Release Bot <[email protected]>
  • Loading branch information
wkal-pubnub and pubnub-release-bot authored Jul 29, 2024
1 parent 4fc3e80 commit 973d1a0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
13 changes: 9 additions & 4 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: kotlin
version: 9.2.2
version: 9.2.3
schema: 1
scm: github.com/pubnub/kotlin
files:
- build/libs/pubnub-kotlin-9.2.2-all.jar
- build/libs/pubnub-kotlin-9.2.3-all.jar
sdks:
-
type: library
Expand All @@ -23,8 +23,8 @@ sdks:
-
distribution-type: library
distribution-repository: maven
package-name: pubnub-kotlin-9.2.2
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/9.2.2/pubnub-kotlin-9.2.2.jar
package-name: pubnub-kotlin-9.2.3
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/9.2.3/pubnub-kotlin-9.2.3.jar
supported-platforms:
supported-operating-systems:
Android:
Expand Down Expand Up @@ -114,6 +114,11 @@ sdks:
license-url: https://www.apache.org/licenses/LICENSE-2.0.txt
is-required: Required
changelog:
- date: 2024-07-29
version: v9.2.3
changes:
- type: bug
text: "Fixed incorrect multiple callbacks (with exception) when sending files."
- date: 2024-07-04
version: v9.2.2
changes:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v9.2.3
July 29 2024

#### Fixed
- Fixed incorrect multiple callbacks (with exception) when sending files.

## v9.2.2
July 04 2024

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ You will need the publish and subscribe keys to authenticate your app. Get your
<dependency>
<groupId>com.pubnub</groupId>
<artifactId>pubnub-kotlin</artifactId>
<version>9.2.2</version>
<version>9.2.3</version>
</dependency>
```

* for Gradle, add the following dependency in your `gradle.build`:
```groovy
implementation 'com.pubnub:pubnub-kotlin:9.2.2'
implementation 'com.pubnub:pubnub-kotlin:9.2.3'
```

2. Configure your keys and create PubNub instance:
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RELEASE_SIGNING_ENABLED=true
SONATYPE_HOST=DEFAULT
SONATYPE_AUTOMATIC_RELEASE=false
GROUP=com.pubnub
VERSION_NAME=9.2.2
VERSION_NAME=9.2.3
POM_PACKAGING=jar

POM_NAME=PubNub SDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ internal class RetryingRemoteAction<T>(
for (i in 0 until maxNumberOfAutomaticRetries) {
try {
callback.accept(Result.success(remoteAction.sync()))
return@Runnable
} catch (e: Throwable) {
lastException = e
}
}
callback.accept(Result.failure(PubNubException.from(lastException!!).copy(remoteAction = this)))
lastException?.let { exception ->
callback.accept(Result.failure(PubNubException.from(exception).copy(remoteAction = this)))
}
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class PubNubCoreTest : BaseTest() {
fun getVersionAndTimeStamp() {
val version = PubNubCore.SDK_VERSION
val timeStamp = PubNubCore.timestamp()
assertEquals("9.2.2", version)
assertEquals("9.2.3", version)
assertTrue(timeStamp > 0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class RetryingRemoteActionTest {
executorService,
)
val asyncSynchronization = CountDownLatch(1)
val noFailureCallsSynchronization = CountDownLatch(1)

// when
retryingRemoteAction.async { result ->
Expand All @@ -98,11 +99,17 @@ class RetryingRemoteActionTest {
Assert.assertEquals(expectedValue, it)
verify(exactly = 1) { remoteAction.sync() }
asyncSynchronization.countDown()
}.onFailure {
noFailureCallsSynchronization.countDown()
}
}
if (!asyncSynchronization.await(3, TimeUnit.SECONDS)) {
Assert.fail("Callback have not been called")
}

if (noFailureCallsSynchronization.await(3, TimeUnit.SECONDS)) {
Assert.fail("onFailure has been called when it shouldn't!")
}
}

@Test
Expand Down

0 comments on commit 973d1a0

Please sign in to comment.