Skip to content

Commit 14acc3b

Browse files
authored
datastore(fix): Fixes previous PR which was inadvertently creating multiple websockets. (#2719)
1 parent 1804551 commit 14acc3b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

aws-api/src/main/java/com/amplifyframework/api/aws/SubscriptionEndpoint.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,17 @@ <T> void requestSubscription(
141141
pendingSubscriptionIds.add(subscriptionId);
142142
socketListener = webSocketListener;
143143
socket = webSocket;
144-
}
145144

146-
// Every request waits here for the connection to be ready.
147-
Connection connection = socketListener.waitForConnectionReady();
148-
if (connection.hasFailure()) {
149-
// If the latch didn't count all the way down
150-
if (pendingSubscriptionIds.remove(subscriptionId)) {
151-
// The subscription was pending, so we need to emit an error.
152-
onSubscriptionError.accept(
153-
new ApiException(connection.getFailureReason(), AmplifyException.TODO_RECOVERY_SUGGESTION));
154-
return;
145+
// Every request waits here for the connection to be ready.
146+
Connection connection = socketListener.waitForConnectionReady();
147+
if (connection.hasFailure()) {
148+
// If the latch didn't count all the way down
149+
if (pendingSubscriptionIds.remove(subscriptionId)) {
150+
// The subscription was pending, so we need to emit an error.
151+
onSubscriptionError.accept(
152+
new ApiException(connection.getFailureReason(), AmplifyException.TODO_RECOVERY_SUGGESTION));
153+
return;
154+
}
155155
}
156156
}
157157

@@ -257,7 +257,7 @@ private void notifySubscriptionData(String subscriptionId, String data) throws A
257257
dispatcher.dispatchNextMessage(data);
258258
}
259259

260-
synchronized void releaseSubscription(String subscriptionId) throws ApiException {
260+
void releaseSubscription(String subscriptionId) throws ApiException {
261261
// First thing we should do is remove it from the pending subscription collection so
262262
// the other methods can't grab a hold of the subscription.
263263
final Subscription<?> subscription = subscriptions.get(subscriptionId);

0 commit comments

Comments
 (0)