Skip to content

Commit 720bcf4

Browse files
committed
[ECO-5418] Marked ObjectsPlugin field as Nullable in AblyRealtime
and RealtimeChannel classes
1 parent a49e370 commit 720bcf4

6 files changed

Lines changed: 12 additions & 5 deletions

File tree

java/src/main/java/io/ably/lib/realtime/Channel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import io.ably.lib.objects.ObjectsPlugin;
44
import io.ably.lib.types.AblyException;
55
import io.ably.lib.types.ChannelOptions;
6+
import org.jetbrains.annotations.Nullable;
67

78
public class Channel extends ChannelBase {
8-
Channel(AblyRealtime ably, String name, ChannelOptions options, ObjectsPlugin objectsPlugin) throws AblyException {
9+
Channel(AblyRealtime ably, String name, ChannelOptions options, @Nullable ObjectsPlugin objectsPlugin) throws AblyException {
910
super(ably, name, options, objectsPlugin);
1011
}
1112

lib/src/main/java/io/ably/lib/objects/ObjectsHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.ably.lib.realtime.AblyRealtime;
44
import io.ably.lib.util.Log;
5+
import org.jetbrains.annotations.Nullable;
56

67
import java.lang.reflect.InvocationTargetException;
78

@@ -10,6 +11,7 @@ public class ObjectsHelper {
1011
private static final String TAG = ObjectsHelper.class.getName();
1112
private static volatile ObjectsSerializer objectsSerializer;
1213

14+
@Nullable
1315
public static ObjectsPlugin tryInitializeObjectsPlugin(AblyRealtime ablyRealtime) {
1416
try {
1517
Class<?> objectsImplementation = Class.forName("io.ably.lib.objects.DefaultObjectsPlugin");
@@ -24,6 +26,7 @@ public static ObjectsPlugin tryInitializeObjectsPlugin(AblyRealtime ablyRealtime
2426
}
2527
}
2628

29+
@Nullable
2730
public static ObjectsSerializer getSerializer() {
2831
if (objectsSerializer == null) {
2932
synchronized (ObjectsHelper.class) {

lib/src/main/java/io/ably/lib/realtime/AblyRealtime.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.ably.lib.util.InternalMap;
2121
import io.ably.lib.util.Log;
2222
import io.ably.lib.util.StringUtils;
23+
import org.jetbrains.annotations.Nullable;
2324

2425
/**
2526
* A client that extends the functionality of the {@link AblyRest} and provides additional realtime-specific features.
@@ -47,6 +48,7 @@ public class AblyRealtime extends AblyRest {
4748
* <p>
4849
* This field is initialized only if the LiveObjects plugin is present in the classpath.
4950
*/
51+
@Nullable
5052
private final ObjectsPlugin objectsPlugin;
5153

5254
/**

lib/src/main/java/io/ably/lib/realtime/ChannelBase.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import io.ably.lib.util.Log;
4444
import io.ably.lib.util.ReconnectionStrategy;
4545
import io.ably.lib.util.StringUtils;
46+
import org.jetbrains.annotations.Nullable;
4647

4748
/**
4849
* Enables messages to be published and subscribed to.
@@ -94,7 +95,7 @@ public abstract class ChannelBase extends EventEmitter<ChannelEvent, ChannelStat
9495
*/
9596
private boolean released = false;
9697

97-
private final ObjectsPlugin objectsPlugin;
98+
@Nullable private final ObjectsPlugin objectsPlugin;
9899

99100
public RealtimeObjects getObjects() throws AblyException {
100101
if (objectsPlugin == null) {
@@ -1325,7 +1326,7 @@ else if(stateChange.current.equals(failureState)) {
13251326
}
13261327
}
13271328

1328-
ChannelBase(AblyRealtime ably, String name, ChannelOptions options, ObjectsPlugin objectsPlugin) throws AblyException {
1329+
ChannelBase(AblyRealtime ably, String name, ChannelOptions options, @Nullable ObjectsPlugin objectsPlugin) throws AblyException {
13291330
Log.v(TAG, "RealtimeChannel(); channel = " + name);
13301331
this.ably = ably;
13311332
this.name = name;

live-objects/src/main/kotlin/io/ably/lib/objects/DefaultObjectsPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public class DefaultObjectsPlugin(private val adapter: ObjectsAdapter) : Objects
2222
}
2323

2424
override fun dispose(channelName: String) {
25-
objects[channelName]?.dispose(clientError("Channel has been released using channels.release()"))
2625
objects.remove(channelName)
26+
?.dispose(clientError("Channel has been released using channels.release()"))
2727
}
2828

2929
override fun dispose() {

live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal class ObjectsManager(private val realtimeObjects: DefaultRealtimeObject
3333
// Some of the incoming object messages may have already been applied to the objects described in
3434
// the sync sequence, but others may not; therefore we must buffer these messages so that we can apply
3535
// them to the objects once the sync is complete.
36-
Log.v(tag, "Buffering ${objectMessages.size} object messages, state: $realtimeObjects.state")
36+
Log.v(tag, "Buffering ${objectMessages.size} object messages, state: ${realtimeObjects.state}")
3737
bufferedObjectOperations.addAll(objectMessages) // RTO8a
3838
return
3939
}

0 commit comments

Comments
 (0)