Skip to content

Commit 826e81c

Browse files
PubNub SDK v5.1.2 release.
1 parent 7e4c137 commit 826e81c

File tree

14 files changed

+273
-249
lines changed

14 files changed

+273
-249
lines changed

.pubnub.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
name: kotlin
2-
version: 5.1.1
2+
version: 5.1.2
33
schema: 1
44
scm: github.com/pubnub/kotlin
55
files:
6-
- build/libs/pubnub-kotlin-5.1.1-all.jar
6+
- build/libs/pubnub-kotlin-5.1.2-all.jar
77
changelog:
8+
-
9+
version: v5.1.2
10+
date: 2021-03-09
11+
changes:
12+
-
13+
type: bug
14+
text: "In some specific timing conditions subscription loop could loose reference to one of the retrofit call and we would loose posibility to control it. In the meantime we'd start yet another subscription call. One of them is obviously not necessary Synchronization has been improved so it's no longer possible."
15+
-
16+
type: bug
17+
text: "It was not possible to properly cancel the OkHttp connection when Google Security Provider (ProviderInstaller) is being used."
818
-
919
version: v5.1.1
1020
date: 2021-01-20

CHANGELOG.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
## [v5.1.1](https://github.com/pubnub/kotlin/releases/tag/v5.1.1)
2-
January 20 2021
1+
## [v5.1.2](https://github.com/pubnub/kotlin/releases/tag/v5.1.2)
2+
March 9 2021
33

4-
[Full Changelog](https://github.com/pubnub/kotlin/compare/v5.1.0...v5.1.1)
4+
[Full Changelog](https://github.com/pubnub/kotlin/compare/v5.1.1...v5.1.2)
55

6-
- File upload encryption fix.
7-
- Asynchronous file upload encryption fix.
8-
- Telemetry fix - removal of `putIfAbsent`.
6+
- In some specific timing conditions subscription loop could loose reference to one of the retrofit call and we would loose posibility to control it. In the meantime we'd start yet another subscription call. One of them is obviously not necessary Synchronization has been improved so it's no longer possible.
7+
- It was not possible to properly cancel the OkHttp connection when Google Security Provider (ProviderInstaller) is being used.
98

109

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
2323
<dependency>
2424
<groupId>com.pubnub</groupId>
2525
<artifactId>pubnub-gson</artifactId>
26-
<version>5.0.2</version>
26+
<version>5.1.2</version>
2727
</dependency>
2828
```
2929

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212
}
1313

1414
group = 'com.pubnub'
15-
version = '5.1.0'
15+
version = '5.1.2'
1616

1717
repositories {
1818
mavenCentral()

src/main/kotlin/com/pubnub/api/PubNub.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class PubNub(val configuration: PNConfiguration) {
7979

8080
private companion object Constants {
8181
private const val TIMESTAMP_DIVIDER = 1000
82-
private const val SDK_VERSION = "5.1.1"
82+
private const val SDK_VERSION = "5.1.2"
8383
private const val MAX_SEQUENCE = 65535
8484
}
8585

Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
package com.pubnub.api.builder
22

33
// basic publish/subscribe class
4-
5-
internal abstract class PubSubOperation(
6-
internal val channels: List<String> = emptyList(),
7-
internal val channelGroups: List<String> = emptyList()
8-
)
4+
internal sealed class PubSubOperation
95

106
// concrete publish/subscribe cases
7+
internal data class SubscribeOperation(
8+
val channels: List<String> = emptyList(),
9+
val channelGroups: List<String> = emptyList(),
10+
val presenceEnabled: Boolean = false,
11+
val timetoken: Long = 0L
12+
) : PubSubOperation()
13+
14+
internal data class UnsubscribeOperation(
15+
val channels: List<String> = emptyList(),
16+
val channelGroups: List<String> = emptyList()
17+
) : PubSubOperation()
18+
19+
internal data class PresenceOperation(
20+
val channels: List<String> = emptyList(),
21+
val channelGroups: List<String> = emptyList(),
22+
val connected: Boolean = false
23+
) : PubSubOperation()
1124

12-
internal class SubscribeOperation(
13-
channels: List<String> = emptyList(),
14-
channelGroups: List<String> = emptyList(),
15-
internal val presenceEnabled: Boolean = false,
16-
internal val timetoken: Long = 0L
17-
) : PubSubOperation(channels, channelGroups)
18-
19-
internal class UnsubscribeOperation(
20-
channels: List<String> = emptyList(),
21-
channelGroups: List<String> = emptyList()
22-
) : PubSubOperation(channels, channelGroups)
23-
24-
internal class PresenceOperation(
25-
channels: List<String> = emptyList(),
26-
channelGroups: List<String> = emptyList(),
27-
internal val connected: Boolean = false
28-
) : PubSubOperation(channels, channelGroups)
29-
30-
internal class StateOperation(
31-
channels: List<String> = emptyList(),
32-
channelGroups: List<String> = emptyList(),
25+
internal data class StateOperation(
26+
val channels: List<String> = emptyList(),
27+
val channelGroups: List<String> = emptyList(),
3328
val state: Any? = null
34-
) : PubSubOperation(channels, channelGroups)
29+
) : PubSubOperation()
30+
31+
internal data class TimetokenRegionOperation(
32+
val timetoken: Long = 0L,
33+
val region: String
34+
) : PubSubOperation()
35+
36+
internal object ConnectedStatusAnnouncedOperation : PubSubOperation()
37+
38+
internal object NoOpOperation : PubSubOperation()

src/main/kotlin/com/pubnub/api/managers/DuplicationManager.kt

+3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ internal class DuplicationManager(private val config: PNConfiguration) {
1212
"${publishMetaData?.publishTimetoken}-${payload.hashCode()}"
1313
}
1414

15+
@Synchronized
1516
fun isDuplicate(message: SubscribeMessage) = hashHistory.contains(getKey(message))
1617

18+
@Synchronized
1719
fun addEntry(message: SubscribeMessage) {
1820
if (hashHistory.size >= config.maximumMessagesCacheSize) {
1921
hashHistory.removeAt(0)
2022
}
2123
hashHistory.add(getKey(message))
2224
}
2325

26+
@Synchronized
2427
fun clearHistory() = hashHistory.clear()
2528
}

src/main/kotlin/com/pubnub/api/managers/ListenerManager.kt

-7
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,30 @@ internal class ListenerManager(val pubnub: PubNub) {
3434
return tempCallbackList
3535
}
3636

37-
@Synchronized
3837
fun announce(status: PNStatus) {
3938
getListeners().forEach { it.status(pubnub, status) }
4039
}
4140

42-
@Synchronized
4341
fun announce(message: PNMessageResult) {
4442
getListeners().forEach { it.message(pubnub, message) }
4543
}
4644

47-
@Synchronized
4845
fun announce(presence: PNPresenceEventResult) {
4946
getListeners().forEach { it.presence(pubnub, presence) }
5047
}
5148

52-
@Synchronized
5349
fun announce(signal: PNSignalResult) {
5450
getListeners().forEach { it.signal(pubnub, signal) }
5551
}
5652

57-
@Synchronized
5853
fun announce(messageAction: PNMessageActionResult) {
5954
getListeners().forEach { it.messageAction(pubnub, messageAction) }
6055
}
6156

62-
@Synchronized
6357
fun announce(pnObjectEventResult: PNObjectEventResult) {
6458
getListeners().forEach { it.objects(pubnub, pnObjectEventResult) }
6559
}
6660

67-
@Synchronized
6861
fun announce(pnFileEventResult: PNFileEventResult) {
6962
getListeners().forEach { it.file(pubnub, pnFileEventResult) }
7063
}

src/main/kotlin/com/pubnub/api/managers/RetrofitManager.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import com.pubnub.api.services.S3Service
1616
import com.pubnub.api.services.SignalService
1717
import com.pubnub.api.services.SubscribeService
1818
import com.pubnub.api.services.TimeService
19+
import okhttp3.Call
1920
import okhttp3.OkHttpClient
21+
import okhttp3.PNCallFactory
2022
import okhttp3.logging.HttpLoggingInterceptor
2123
import retrofit2.Retrofit
2224
import java.util.concurrent.ExecutorService
@@ -57,7 +59,7 @@ class RetrofitManager(val pubnub: PubNub) {
5759
}
5860

5961
val transactionInstance = createRetrofit(transactionClientInstance)
60-
val subscriptionInstance = createRetrofit(subscriptionClientInstance)
62+
val subscriptionInstance = createRetrofit(PNCallFactory(subscriptionClientInstance))
6163
val noSignatureInstance = createRetrofit(noSignatureClientInstance)
6264

6365
timeService = transactionInstance.create(TimeService::class.java)
@@ -122,9 +124,9 @@ class RetrofitManager(val pubnub: PubNub) {
122124
return okHttpClient
123125
}
124126

125-
private fun createRetrofit(okHttpClient: OkHttpClient): Retrofit {
127+
private fun createRetrofit(callFactory: Call.Factory): Retrofit {
126128
val retrofitBuilder = Retrofit.Builder()
127-
.client(okHttpClient)
129+
.callFactory(callFactory)
128130
.baseUrl(pubnub.baseUrl())
129131
.addConverterFactory(pubnub.mapper.converterFactory)
130132

0 commit comments

Comments
 (0)