Skip to content

Commit 2c6682c

Browse files
Merge pull request #621 from firebase/mrschmidt-fixrace
Fixing potential race in ServerTimestamp tests
2 parents 275b4e5 + ed6c6f9 commit 2c6682c

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,19 @@ - (void)writeInitialData {
101101

102102
/** Waits for a snapshot with local writes. */
103103
- (FIRDocumentSnapshot *)waitForLocalEvent {
104-
FIRDocumentSnapshot *snapshot = [_accumulator awaitEventWithName:@"Local event."];
105-
XCTAssertTrue(snapshot.metadata.hasPendingWrites);
104+
FIRDocumentSnapshot *snapshot;
105+
do {
106+
snapshot = [_accumulator awaitEventWithName:@"Local event."];
107+
} while (!snapshot.metadata.hasPendingWrites);
106108
return snapshot;
107109
}
108110

109111
/** Waits for a snapshot that has no pending writes */
110112
- (FIRDocumentSnapshot *)waitForRemoteEvent {
111-
FIRDocumentSnapshot *snapshot = [_accumulator awaitEventWithName:@"Remote event."];
112-
XCTAssertFalse(snapshot.metadata.hasPendingWrites);
113+
FIRDocumentSnapshot *snapshot;
114+
do {
115+
snapshot = [_accumulator awaitEventWithName:@"Remote event."];
116+
} while (snapshot.metadata.hasPendingWrites);
113117
return snapshot;
114118
}
115119

Firestore/Example/Tests/Remote/FSTSerializerBetaTests.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,7 @@ - (void)testEncodesNestedObjects {
267267
@"i" : @1,
268268
@"n" : [NSNull null],
269269
@"s" : @"foo",
270-
@"a" : @[ @2, @"bar",
271-
@{ @"b" : @NO } ],
270+
@"a" : @[ @2, @"bar", @{@"b" : @NO} ],
272271
@"o" : @{
273272
@"d" : @100,
274273
@"nested" : @{@"e" : @(LLONG_MIN)},

Firestore/Source/API/FIRFirestore.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ - (instancetype)initWithProjectID:(NSString *)projectID
158158
}
159159

160160
- (FIRFirestoreSettings *)settings {
161-
@synchronized (self) {
161+
@synchronized(self) {
162162
// Disallow mutation of our internal settings
163163
return [_settings copy];
164164
}
165165
}
166166

167167
- (void)setSettings:(FIRFirestoreSettings *)settings {
168-
@synchronized (self) {
168+
@synchronized(self) {
169169
// As a special exception, don't throw if the same settings are passed repeatedly. This should
170170
// make it more friendly to create a Firestore instance.
171171
if (_client && ![_settings isEqual:settings]) {
@@ -187,17 +187,17 @@ - (FSTFirestoreClient *)client {
187187
}
188188

189189
- (void)ensureClientConfigured {
190-
@synchronized (self) {
190+
@synchronized(self) {
191191
if (!_client) {
192192
// These values are validated elsewhere; this is just double-checking:
193193
FSTAssert(_settings.host, @"FirestoreSettings.host cannot be nil.");
194194
FSTAssert(_settings.dispatchQueue, @"FirestoreSettings.dispatchQueue cannot be nil.");
195195

196196
FSTDatabaseInfo *databaseInfo =
197-
[FSTDatabaseInfo databaseInfoWithDatabaseID:_databaseID
198-
persistenceKey:_persistenceKey
199-
host:_settings.host
200-
sslEnabled:_settings.sslEnabled];
197+
[FSTDatabaseInfo databaseInfoWithDatabaseID:_databaseID
198+
persistenceKey:_persistenceKey
199+
host:_settings.host
200+
sslEnabled:_settings.sslEnabled];
201201

202202
FSTDispatchQueue *userDispatchQueue = [FSTDispatchQueue queueWith:_settings.dispatchQueue];
203203

@@ -280,7 +280,7 @@ - (void)runTransactionWithBlock:(id _Nullable (^)(FIRTransaction *, NSError **er
280280

281281
- (void)shutdownWithCompletion:(nullable void (^)(NSError *_Nullable error))completion {
282282
FSTFirestoreClient *client;
283-
@synchronized (self) {
283+
@synchronized(self) {
284284
client = _client;
285285
_client = nil;
286286
}

0 commit comments

Comments
 (0)