diff --git a/.pubnub.yml b/.pubnub.yml
index 9e87fe1d8..e5962fe11 100644
--- a/.pubnub.yml
+++ b/.pubnub.yml
@@ -1,9 +1,9 @@
name: java
-version: 4.36.0
+version: 5.0.0
schema: 1
scm: github.com/pubnub/java
files:
- - build/libs/pubnub-gson-4.36.0-all.jar
+ - build/libs/pubnub-gson-5.0.0-all.jar
sdks:
-
type: library
@@ -234,6 +234,13 @@ sdks:
is-required: Required
changelog:
+ - version: v5.0.0
+ date: 2021-05-12
+ changes:
+ - type: feature
+ text: "Now random initialisation vector used when encryption enabled is now default behaviour."
+ - type: bug
+ text: "There were some non daemon threads running in background preventing VM from exiting. Now they are daemon threads."
- version: v4.36.0
date: 2021-04-08
changes:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b2744d34a..84e3d4198 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,14 @@
+## [v5.0.0](https://github.com/pubnub/java/releases/tag/v5.0.0)
+May-12-2021
+
+[Full Changelog](https://github.com/pubnub/java/compare/v4.36.0...v5.0.0)
+
+- 🌟️ Now random initialisation vector used when encryption enabled is now default behaviour.
+- 🐛 There were some non daemon threads running in background preventing VM from exiting. Now they are daemon threads.
+
## [v4.36.0](https://github.com/pubnub/java/releases/tag/v4.36.0)
April-08-2021
-[Full Changelog](https://github.com/pubnub/java/compare/v4.35.0...v4.36.0)
-
- 🌟️ New way of controlling Presence by Heartbeat calls for purpose of usage with dedicated server configuration (ACL). This feature can be used only with additional support from PubNub.
## [v4.33.3](https://github.com/pubnub/java/releases/tag/v4.33.3)
diff --git a/README.md b/README.md
index dd820fd87..3246be6a6 100644
--- a/README.md
+++ b/README.md
@@ -23,13 +23,13 @@ You will need the publish and subscribe keys to authenticate your app. Get your
com.pubnub
pubnub-gson
- 4.36.0
+ 5.0.0
```
* for Gradle, add the following dependency in your `gradle.build`:
```groovy
- compile group: 'com.pubnub', name: 'pubnub-gson', version: '4.36.0'
+ compile group: 'com.pubnub', name: 'pubnub-gson', version: '5.0.0'
```
2. Configure your keys:
diff --git a/build.gradle b/build.gradle
index 8c5f28f97..46f64b819 100644
--- a/build.gradle
+++ b/build.gradle
@@ -11,7 +11,7 @@ plugins {
}
group = 'com.pubnub'
-version = '4.36.0'
+version = '5.0.0'
description = """"""
diff --git a/src/main/java/com/pubnub/api/PNConfiguration.java b/src/main/java/com/pubnub/api/PNConfiguration.java
index 1e5d189f4..f31737596 100644
--- a/src/main/java/com/pubnub/api/PNConfiguration.java
+++ b/src/main/java/com/pubnub/api/PNConfiguration.java
@@ -236,7 +236,7 @@ public PNConfiguration() {
dedupOnSubscribe = false;
suppressLeaveEvents = false;
maximumMessagesCacheSize = DEFAULT_DEDUPE_SIZE;
- useRandomInitializationVector = false;
+ useRandomInitializationVector = true;
fileMessagePublishRetryLimit = FILE_MESSAGE_PUBLISH_RETRY_LIMIT;
managePresenceListManually = false;
}
diff --git a/src/main/java/com/pubnub/api/PubNub.java b/src/main/java/com/pubnub/api/PubNub.java
index d3cdcbc5d..da48acaba 100644
--- a/src/main/java/com/pubnub/api/PubNub.java
+++ b/src/main/java/com/pubnub/api/PubNub.java
@@ -97,7 +97,7 @@ public class PubNub {
private static final int TIMESTAMP_DIVIDER = 1000;
private static final int MAX_SEQUENCE = 65535;
- private static final String SDK_VERSION = "4.36.0";
+ private static final String SDK_VERSION = "5.0.0";
private final ListenerManager listenerManager;
private final StateManager stateManager;
diff --git a/src/main/java/com/pubnub/api/builder/PubNubErrorBuilder.java b/src/main/java/com/pubnub/api/builder/PubNubErrorBuilder.java
index c244d1a0c..614fbbafc 100644
--- a/src/main/java/com/pubnub/api/builder/PubNubErrorBuilder.java
+++ b/src/main/java/com/pubnub/api/builder/PubNubErrorBuilder.java
@@ -159,7 +159,7 @@ public final class PubNubErrorBuilder {
/**
* Subscribe Timeout .
*/
- public static final int PNERR_HTTP_SUBSCRIBE_TIMEOUT = 130;
+ public static final int PNERR_HTTP_SOCKET_TIMEOUT = 130;
/**
* Invalid arguments provided to API
@@ -509,9 +509,9 @@ public final class PubNubErrorBuilder {
.message("Page Not Found Please verify if network is reachable. Please contact support with error details.")
.build();
- public static final PubNubError PNERROBJ_SUBSCRIBE_TIMEOUT = PubNubError.builder()
- .errorCode(PNERR_HTTP_SUBSCRIBE_TIMEOUT)
- .message("Subscribe Timeout.")
+ public static final PubNubError PNERROBJ_SOCKET_TIMEOUT = PubNubError.builder()
+ .errorCode(PNERR_HTTP_SOCKET_TIMEOUT)
+ .message("Socket Timeout.")
.build();
public static final PubNubError PNERROBJ_INVALID_ARGUMENTS = PubNubError.builder()
diff --git a/src/main/java/com/pubnub/api/endpoints/Endpoint.java b/src/main/java/com/pubnub/api/endpoints/Endpoint.java
index 5285371ce..f6543497d 100644
--- a/src/main/java/com/pubnub/api/endpoints/Endpoint.java
+++ b/src/main/java/com/pubnub/api/endpoints/Endpoint.java
@@ -238,7 +238,7 @@ public void onFailure(Call performedCall, Throwable throwable) {
pubnubException.pubnubError(PubNubErrorBuilder.PNERROBJ_CONNECT_EXCEPTION);
pnStatusCategory = PNStatusCategory.PNUnexpectedDisconnectCategory;
} catch (SocketTimeoutException socketTimeoutException) {
- pubnubException.pubnubError(PubNubErrorBuilder.PNERROBJ_SUBSCRIBE_TIMEOUT);
+ pubnubException.pubnubError(PubNubErrorBuilder.PNERROBJ_SOCKET_TIMEOUT);
pnStatusCategory = PNStatusCategory.PNTimeoutCategory;
} catch (Throwable throwable1) {
pubnubException.pubnubError(PubNubErrorBuilder.PNERROBJ_HTTP_ERROR);
diff --git a/src/main/java/com/pubnub/api/endpoints/files/UploadFile.java b/src/main/java/com/pubnub/api/endpoints/files/UploadFile.java
index 3fdcac38a..d087d0446 100644
--- a/src/main/java/com/pubnub/api/endpoints/files/UploadFile.java
+++ b/src/main/java/com/pubnub/api/endpoints/files/UploadFile.java
@@ -203,7 +203,7 @@ public void onFailure(@NotNull Call performedCall, @NotNull Throwable thro
pubnubException.pubnubError(PubNubErrorBuilder.PNERROBJ_CONNECT_EXCEPTION);
pnStatusCategory = PNStatusCategory.PNUnexpectedDisconnectCategory;
} catch (SocketTimeoutException socketTimeoutException) {
- pubnubException.pubnubError(PubNubErrorBuilder.PNERROBJ_SUBSCRIBE_TIMEOUT);
+ pubnubException.pubnubError(PubNubErrorBuilder.PNERROBJ_SOCKET_TIMEOUT);
pnStatusCategory = PNStatusCategory.PNTimeoutCategory;
} catch (Throwable throwable1) {
pubnubException.pubnubError(PubNubErrorBuilder.PNERROBJ_HTTP_ERROR);
diff --git a/src/main/java/com/pubnub/api/managers/DelayedReconnectionManager.java b/src/main/java/com/pubnub/api/managers/DelayedReconnectionManager.java
index 28bf03033..7a84b8599 100644
--- a/src/main/java/com/pubnub/api/managers/DelayedReconnectionManager.java
+++ b/src/main/java/com/pubnub/api/managers/DelayedReconnectionManager.java
@@ -33,7 +33,7 @@ public void scheduleDelayedReconnection() {
return;
}
- timer = new Timer();
+ timer = new Timer("Delayed Reconnection Manager timer", true);
timer.schedule(new TimerTask() {
@Override
public void run() {
diff --git a/src/main/java/com/pubnub/api/managers/ReconnectionManager.java b/src/main/java/com/pubnub/api/managers/ReconnectionManager.java
index fe0d83268..7a1cc4858 100644
--- a/src/main/java/com/pubnub/api/managers/ReconnectionManager.java
+++ b/src/main/java/com/pubnub/api/managers/ReconnectionManager.java
@@ -71,7 +71,7 @@ private void registerHeartbeatTimer() {
return;
}
- timer = new Timer();
+ timer = new Timer("Reconnection Manager timer", true);
timer.schedule(new TimerTask() {
@Override
diff --git a/src/main/java/com/pubnub/api/managers/RetrofitManager.java b/src/main/java/com/pubnub/api/managers/RetrofitManager.java
index 006e53537..32b8678ed 100644
--- a/src/main/java/com/pubnub/api/managers/RetrofitManager.java
+++ b/src/main/java/com/pubnub/api/managers/RetrofitManager.java
@@ -228,5 +228,8 @@ public void destroy(boolean force) {
if (this.subscriptionClientInstance != null) {
closeExecutor(this.subscriptionClientInstance, force);
}
+ if (this.noSignatureClientInstance != null) {
+ closeExecutor(this.noSignatureClientInstance, force);
+ }
}
}
diff --git a/src/main/java/com/pubnub/api/managers/SubscriptionManager.java b/src/main/java/com/pubnub/api/managers/SubscriptionManager.java
index 3d24aa6f7..12490c987 100644
--- a/src/main/java/com/pubnub/api/managers/SubscriptionManager.java
+++ b/src/main/java/com/pubnub/api/managers/SubscriptionManager.java
@@ -123,6 +123,7 @@ public void onMaxReconnectionExhaustion() {
consumerThread = new Thread(new SubscribeMessageWorker(
this.pubnub, listenerManager, messageQueue, duplicationManager));
consumerThread.setName("Subscription Manager Consumer Thread");
+ consumerThread.setDaemon(true);
consumerThread.start();
}
}
@@ -213,7 +214,7 @@ private synchronized void registerHeartbeatTimer(PubSubOperation pubSubOperation
return;
}
- timer = new Timer();
+ timer = new Timer("Subscription Manager Heartbeat Timer", true);
timer.schedule(new TimerTask() {
@Override
public void run() {
@@ -240,7 +241,7 @@ private synchronized void cancelDelayedLoopIterationForTemporaryUnavailableChann
private void scheduleDelayedLoopIterationForTemporaryUnavailableChannels() {
cancelDelayedLoopIterationForTemporaryUnavailableChannels();
- temporaryUnavailableChannelsDelayer = new Timer();
+ temporaryUnavailableChannelsDelayer = new Timer("Subscription Manager TMP Unavailable Channel Delayer", true);
temporaryUnavailableChannelsDelayer.schedule(new TimerTask() {
@Override
public void run() {
diff --git a/src/main/java/com/pubnub/api/managers/TelemetryManager.java b/src/main/java/com/pubnub/api/managers/TelemetryManager.java
index d396be64f..64b9d34aa 100644
--- a/src/main/java/com/pubnub/api/managers/TelemetryManager.java
+++ b/src/main/java/com/pubnub/api/managers/TelemetryManager.java
@@ -98,7 +98,7 @@ private void startCleanUpTimer() {
long interval = CLEAN_UP_INTERVAL * CLEAN_UP_INTERVAL_MULTIPLIER;
stopCleanUpTimer();
- this.timer = new Timer();
+ this.timer = new Timer("Telemetry Manager timer", true);
this.timer.schedule(new TimerTask() {
@Override
public void run() {
diff --git a/src/main/java/com/pubnub/api/workers/SubscribeMessageWorker.java b/src/main/java/com/pubnub/api/workers/SubscribeMessageWorker.java
index 63317761f..65f74982f 100644
--- a/src/main/java/com/pubnub/api/workers/SubscribeMessageWorker.java
+++ b/src/main/java/com/pubnub/api/workers/SubscribeMessageWorker.java
@@ -57,8 +57,6 @@ public class SubscribeMessageWorker implements Runnable {
private LinkedBlockingQueue queue;
private DuplicationManager duplicationManager;
- private boolean isRunning;
-
public SubscribeMessageWorker(PubNub pubnubInstance,
ListenerManager listenerManagerInstance,
LinkedBlockingQueue queueInstance,
@@ -76,13 +74,11 @@ public void run() {
private void takeMessage() {
- this.isRunning = true;
-
- while (this.isRunning) {
+ while (!Thread.interrupted()) {
try {
this.processIncomingPayload(this.queue.take());
} catch (InterruptedException e) {
- this.isRunning = false;
+ Thread.currentThread().interrupt();
log.trace("take message interrupted", e);
}
}
diff --git a/src/test/java/com/pubnub/api/PubNubTest.java b/src/test/java/com/pubnub/api/PubNubTest.java
index aeef04730..933c7e465 100644
--- a/src/test/java/com/pubnub/api/PubNubTest.java
+++ b/src/test/java/com/pubnub/api/PubNubTest.java
@@ -17,6 +17,7 @@ public void beforeEach() throws IOException {
pnConfiguration = new PNConfiguration();
pnConfiguration.setSubscribeKey("demo");
pnConfiguration.setPublishKey("demo");
+ pnConfiguration.setUseRandomInitializationVector(false);
}
@After
@@ -98,7 +99,7 @@ public void getVersionAndTimeStamp() {
pubnub = new PubNub(pnConfiguration);
String version = pubnub.getVersion();
int timeStamp = pubnub.getTimestamp();
- Assert.assertEquals("4.36.0", version);
+ Assert.assertEquals("5.0.0", version);
Assert.assertTrue(timeStamp > 0);
}
diff --git a/src/test/java/com/pubnub/api/endpoints/TestHarness.java b/src/test/java/com/pubnub/api/endpoints/TestHarness.java
index b5f85bd75..b6fb21982 100644
--- a/src/test/java/com/pubnub/api/endpoints/TestHarness.java
+++ b/src/test/java/com/pubnub/api/endpoints/TestHarness.java
@@ -15,6 +15,7 @@ protected PubNub createPubNubInstance() {
pnConfiguration.setPublishKey("myPublishKey");
pnConfiguration.setUuid("myUUID");
pnConfiguration.setLogVerbosity(PNLogVerbosity.BODY);
+ pnConfiguration.setUseRandomInitializationVector(false);
class MockedTimePubNub extends PubNub {