aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Sebastian Schmidt <mrschmidt@google.com>2018-01-05 10:56:16 -0800
committerGravatar GitHub <noreply@github.com>2018-01-05 10:56:16 -0800
commit2c6682c66ea7b86b3b7cb52e623086b4184d500a (patch)
tree8247e9786c78841e987a8199960ec245e32a8833
parent275b4e5a7633d69b6de36551398e88943dca8432 (diff)
parented6c6f9fea3e1e429972cbd0e65f3fc7c05e41e2 (diff)
Merge pull request #621 from firebase/mrschmidt-fixrace
Fixing potential race in ServerTimestamp tests
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.m12
-rw-r--r--Firestore/Example/Tests/Remote/FSTSerializerBetaTests.m3
-rw-r--r--Firestore/Source/API/FIRFirestore.m16
3 files changed, 17 insertions, 14 deletions
diff --git a/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.m b/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.m
index 5cda053..cc0ab29 100644
--- a/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.m
+++ b/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.m
@@ -101,15 +101,19 @@
/** Waits for a snapshot with local writes. */
- (FIRDocumentSnapshot *)waitForLocalEvent {
- FIRDocumentSnapshot *snapshot = [_accumulator awaitEventWithName:@"Local event."];
- XCTAssertTrue(snapshot.metadata.hasPendingWrites);
+ FIRDocumentSnapshot *snapshot;
+ do {
+ snapshot = [_accumulator awaitEventWithName:@"Local event."];
+ } while (!snapshot.metadata.hasPendingWrites);
return snapshot;
}
/** Waits for a snapshot that has no pending writes */
- (FIRDocumentSnapshot *)waitForRemoteEvent {
- FIRDocumentSnapshot *snapshot = [_accumulator awaitEventWithName:@"Remote event."];
- XCTAssertFalse(snapshot.metadata.hasPendingWrites);
+ FIRDocumentSnapshot *snapshot;
+ do {
+ snapshot = [_accumulator awaitEventWithName:@"Remote event."];
+ } while (snapshot.metadata.hasPendingWrites);
return snapshot;
}
diff --git a/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.m b/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.m
index 61847b0..bba04c5 100644
--- a/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.m
+++ b/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.m
@@ -267,8 +267,7 @@ NS_ASSUME_NONNULL_BEGIN
@"i" : @1,
@"n" : [NSNull null],
@"s" : @"foo",
- @"a" : @[ @2, @"bar",
- @{ @"b" : @NO } ],
+ @"a" : @[ @2, @"bar", @{@"b" : @NO} ],
@"o" : @{
@"d" : @100,
@"nested" : @{@"e" : @(LLONG_MIN)},
diff --git a/Firestore/Source/API/FIRFirestore.m b/Firestore/Source/API/FIRFirestore.m
index b455726..9df3711 100644
--- a/Firestore/Source/API/FIRFirestore.m
+++ b/Firestore/Source/API/FIRFirestore.m
@@ -158,14 +158,14 @@ NSString *const FIRFirestoreErrorDomain = @"FIRFirestoreErrorDomain";
}
- (FIRFirestoreSettings *)settings {
- @synchronized (self) {
+ @synchronized(self) {
// Disallow mutation of our internal settings
return [_settings copy];
}
}
- (void)setSettings:(FIRFirestoreSettings *)settings {
- @synchronized (self) {
+ @synchronized(self) {
// As a special exception, don't throw if the same settings are passed repeatedly. This should
// make it more friendly to create a Firestore instance.
if (_client && ![_settings isEqual:settings]) {
@@ -187,17 +187,17 @@ NSString *const FIRFirestoreErrorDomain = @"FIRFirestoreErrorDomain";
}
- (void)ensureClientConfigured {
- @synchronized (self) {
+ @synchronized(self) {
if (!_client) {
// These values are validated elsewhere; this is just double-checking:
FSTAssert(_settings.host, @"FirestoreSettings.host cannot be nil.");
FSTAssert(_settings.dispatchQueue, @"FirestoreSettings.dispatchQueue cannot be nil.");
FSTDatabaseInfo *databaseInfo =
- [FSTDatabaseInfo databaseInfoWithDatabaseID:_databaseID
- persistenceKey:_persistenceKey
- host:_settings.host
- sslEnabled:_settings.sslEnabled];
+ [FSTDatabaseInfo databaseInfoWithDatabaseID:_databaseID
+ persistenceKey:_persistenceKey
+ host:_settings.host
+ sslEnabled:_settings.sslEnabled];
FSTDispatchQueue *userDispatchQueue = [FSTDispatchQueue queueWith:_settings.dispatchQueue];
@@ -280,7 +280,7 @@ NSString *const FIRFirestoreErrorDomain = @"FIRFirestoreErrorDomain";
- (void)shutdownWithCompletion:(nullable void (^)(NSError *_Nullable error))completion {
FSTFirestoreClient *client;
- @synchronized (self) {
+ @synchronized(self) {
client = _client;
_client = nil;
}