Skip to content

Commit

Permalink
Fix a bug uncovered while writing tests
Browse files Browse the repository at this point in the history
`[handle sessionStillExists]` returns NO if `handle` is `nil`. In this case the session handle shouldn't be considered invalid, since it hasn't yet been registered in the first place.
  • Loading branch information
austinzheng committed Sep 23, 2016
1 parent db1080e commit 144ab89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Realm/RLMSyncSession_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic) NSTimer *refreshTimer;

- (nullable RLMSyncSessionHandle *)sessionHandle;

- (void)configureWithAccessToken:(RLMServerToken)token
expiry:(NSTimeInterval)expiry
user:(RLMSyncUser *)user
Expand Down
9 changes: 3 additions & 6 deletions Realm/RLMSyncUser.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@

using namespace realm;

@interface RLMSyncSession ()
- (id)sessionHandle;
@end

@interface RLMSyncUser ()

- (instancetype)initWithAuthServer:(nullable NSURL *)authServer NS_DESIGNATED_INITIALIZER;
Expand Down Expand Up @@ -113,10 +109,11 @@ - (void)logOut {

- (nullable RLMSyncSession *)sessionForURL:(NSURL *)url {
RLMSyncSession *session = [self.sessionsStorage objectForKey:url];
if (![[session sessionHandle] sessionStillExists]) {
RLMSyncSessionHandle *handle = [session sessionHandle];
if (handle && ![handle sessionStillExists]) {
[self.sessionsStorage removeObjectForKey:url];
return nil;
} else if ([[session sessionHandle] sessionIsInErrorState]) {
} else if ([handle sessionIsInErrorState]) {
[session _invalidate];
return nil;
}
Expand Down

0 comments on commit 144ab89

Please sign in to comment.