@@ -64,6 +64,8 @@ public abstract class AbstractTableSubscription extends HasEventHandling {
6464 protected enum Status {
6565 /** Waiting for some prerequisite before we can use it for the first time. */
6666 STARTING ,
67+ /** All prerequisites are met, waiting for the first snapshot to be returned. */
68+ SUBSCRIPTION_REQUESTED ,
6769 /** Successfully created, not waiting for any messages to be accurate. */
6870 ACTIVE ,
6971 /** Waiting for an update to return from being active to being active again. */
@@ -117,7 +119,11 @@ protected void revive() {
117119 WebBarrageSubscription .ViewportChangedHandler viewportChangedHandler = this ::onViewportChange ;
118120 WebBarrageSubscription .DataChangedHandler dataChangedHandler = this ::onDataChanged ;
119121
120- status = Status .ACTIVE ;
122+ status = Status .SUBSCRIPTION_REQUESTED ;
123+
124+ // In order to create the subscription, we need to already have the table resolved, so we know if it
125+ // is a blink table or not. In turn, we can't be prepared to handle any messages from the server until
126+ // we know this, so we can't race messages with this design.
121127 this .barrageSubscription = WebBarrageSubscription .subscribe (
122128 subscriptionType , state , viewportChangedHandler , dataChangedHandler );
123129
@@ -164,7 +170,8 @@ protected static FlatBufferBuilder subscriptionRequest(byte[] tableTicket, BitSe
164170
165171 protected abstract void sendFirstSubscriptionRequest ();
166172
167- protected void sendBarrageSubscriptionRequest (RangeSet viewport , JsArray <Column > columns , Double updateIntervalMs ,
173+ protected void sendBarrageSubscriptionRequest (@ Nullable RangeSet viewport , JsArray <Column > columns ,
174+ Double updateIntervalMs ,
168175 boolean isReverseViewport ) {
169176 if (isClosed ()) {
170177 if (failMsg == null ) {
@@ -173,7 +180,9 @@ protected void sendBarrageSubscriptionRequest(RangeSet viewport, JsArray<Column>
173180 throw new IllegalStateException ("Can't change subscription, already failed: " + failMsg );
174181 }
175182 }
176- status = Status .PENDING_UPDATE ;
183+ if (status == Status .ACTIVE ) {
184+ status = Status .PENDING_UPDATE ;
185+ }
177186 this .columns = columns ;
178187 this .viewportRowSet = viewport ;
179188 this .columnBitSet = makeColumnBitset (columns );
0 commit comments