Skip to content

Commit 6a68958

Browse files
committed
Fix flaky unit test exit
1 parent fc6557e commit 6a68958

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

Sources/Sentry/SentryHub.m

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
@interface SentryHub ()
3838

39-
@property (nullable, nonatomic, strong) SentryClient *client;
39+
@property (nullable, atomic, strong) SentryClient *client;
4040
@property (nullable, nonatomic, strong) SentryScope *scope;
4141
@property (nonatomic) SentryDispatchQueueWrapper *dispatchQueue;
4242
@property (nonatomic, strong) SentryCrashWrapper *crashWrapper;
@@ -90,7 +90,7 @@ - (void)startSession
9090
{
9191
SentrySession *lastSession = nil;
9292
SentryScope *scope = self.scope;
93-
SentryOptions *options = [_client options];
93+
SentryOptions *options = [self.client options];
9494
if (options == nil) {
9595
SENTRY_LOG_ERROR(@"Options of the client are nil. Not starting a session.");
9696
return;
@@ -158,17 +158,17 @@ - (void)endSessionWithTimestamp:(NSDate *)timestamp
158158

159159
- (void)storeCurrentSession:(SentrySession *)session
160160
{
161-
[[_client fileManager] storeCurrentSession:session];
161+
[[self.client fileManager] storeCurrentSession:session];
162162
}
163163

164164
- (void)deleteCurrentSession
165165
{
166-
[[_client fileManager] deleteCurrentSession];
166+
[[self.client fileManager] deleteCurrentSession];
167167
}
168168

169169
- (void)closeCachedSessionWithTimestamp:(nullable NSDate *)timestamp
170170
{
171-
SentryFileManager *fileManager = [_client fileManager];
171+
SentryFileManager *fileManager = [self.client fileManager];
172172
SentrySession *session = [fileManager readCurrentSession];
173173
if (session == nil) {
174174
SENTRY_LOG_DEBUG(@"No cached session to close.");
@@ -177,7 +177,7 @@ - (void)closeCachedSessionWithTimestamp:(nullable NSDate *)timestamp
177177
SENTRY_LOG_DEBUG(@"A cached session was found.");
178178

179179
// Make sure there's a client bound.
180-
SentryClient *client = _client;
180+
SentryClient *client = self.client;
181181
if (client == nil) {
182182
SENTRY_LOG_DEBUG(@"No client bound.");
183183
return;
@@ -204,7 +204,7 @@ - (void)closeCachedSessionWithTimestamp:(nullable NSDate *)timestamp
204204
- (void)captureSession:(nullable SentrySession *)session
205205
{
206206
if (session != nil) {
207-
SentryClient *client = _client;
207+
SentryClient *client = self.client;
208208

209209
if (client.options.diagnosticLevel == kSentryLevelDebug) {
210210
SENTRY_LOG_DEBUG(
@@ -243,7 +243,7 @@ - (void)captureFatalEvent:(SentryEvent *)event withScope:(SentryScope *)scope
243243
{
244244
event.isFatalEvent = YES;
245245

246-
SentryClient *client = _client;
246+
SentryClient *client = self.client;
247247
if (client == nil) {
248248
return;
249249
}
@@ -337,7 +337,7 @@ - (void)saveCrashTransaction:(SentryTransaction *)transaction
337337
return;
338338
}
339339

340-
SentryClient *client = _client;
340+
SentryClient *client = self.client;
341341
if (client != nil) {
342342
[client saveCrashTransaction:transaction withScope:self.scope];
343343
}
@@ -357,7 +357,7 @@ - (SentryId *)captureEvent:(SentryEvent *)event
357357
withScope:(SentryScope *)scope
358358
additionalEnvelopeItems:(NSArray<SentryEnvelopeItem *> *)additionalEnvelopeItems
359359
{
360-
SentryClient *client = _client;
360+
SentryClient *client = self.client;
361361
if (client != nil) {
362362
return [client captureEvent:event
363363
withScope:scope
@@ -370,10 +370,10 @@ - (void)captureReplayEvent:(SentryReplayEvent *)replayEvent
370370
replayRecording:(SentryReplayRecording *)replayRecording
371371
video:(NSURL *)videoURL
372372
{
373-
[_client captureReplayEvent:replayEvent
374-
replayRecording:replayRecording
375-
video:videoURL
376-
withScope:self.scope];
373+
[self.client captureReplayEvent:replayEvent
374+
replayRecording:replayRecording
375+
video:videoURL
376+
withScope:self.scope];
377377
}
378378

379379
- (id<SentrySpan>)startTransactionWithName:(NSString *)name operation:(NSString *)operation
@@ -489,7 +489,7 @@ - (SentryId *)captureMessage:(NSString *)message
489489

490490
- (SentryId *)captureMessage:(NSString *)message withScope:(SentryScope *)scope
491491
{
492-
SentryClient *client = _client;
492+
SentryClient *client = self.client;
493493
if (client != nil) {
494494
return [client captureMessage:message withScope:scope];
495495
}
@@ -504,7 +504,7 @@ - (SentryId *)captureError:(NSError *)error
504504
- (SentryId *)captureError:(NSError *)error withScope:(SentryScope *)scope
505505
{
506506
SentrySession *currentSession = _session;
507-
SentryClient *client = _client;
507+
SentryClient *client = self.client;
508508
if (client != nil) {
509509
if (currentSession != nil) {
510510
return [client captureError:error
@@ -526,7 +526,7 @@ - (SentryId *)captureException:(NSException *)exception
526526
- (SentryId *)captureException:(NSException *)exception withScope:(SentryScope *)scope
527527
{
528528
SentrySession *currentSession = _session;
529-
SentryClient *client = _client;
529+
SentryClient *client = self.client;
530530
if (client != nil) {
531531
if (currentSession != nil) {
532532
return [client captureException:exception
@@ -542,15 +542,15 @@ - (SentryId *)captureException:(NSException *)exception withScope:(SentryScope *
542542

543543
- (void)captureUserFeedback:(SentryUserFeedback *)userFeedback
544544
{
545-
SentryClient *client = _client;
545+
SentryClient *client = self.client;
546546
if (client != nil) {
547547
[client captureUserFeedback:userFeedback];
548548
}
549549
}
550550

551551
- (void)captureFeedback:(SentryFeedback *)feedback
552552
{
553-
SentryClient *client = _client;
553+
SentryClient *client = self.client;
554554
if (client != nil) {
555555
[client captureFeedback:feedback withScope:self.scope];
556556
}
@@ -575,7 +575,7 @@ - (void)addBreadcrumb:(SentryBreadcrumb *)crumb
575575

576576
- (nullable SentryClient *)getClient
577577
{
578-
return _client;
578+
return self.client;
579579
}
580580

581581
- (void)bindClient:(nullable SentryClient *)client
@@ -587,7 +587,7 @@ - (SentryScope *)scope
587587
{
588588
@synchronized(self) {
589589
if (_scope == nil) {
590-
SentryClient *client = _client;
590+
SentryClient *client = self.client;
591591
if (client != nil) {
592592
_scope = [[SentryScope alloc] initWithMaxBreadcrumbs:client.options.maxBreadcrumbs];
593593
} else {
@@ -695,7 +695,7 @@ - (void)setUser:(nullable SentryUser *)user
695695
*/
696696
- (void)storeEnvelope:(SentryEnvelope *)envelope
697697
{
698-
SentryClient *client = _client;
698+
SentryClient *client = self.client;
699699
if (client == nil) {
700700
return;
701701
}
@@ -707,7 +707,7 @@ - (void)storeEnvelope:(SentryEnvelope *)envelope
707707

708708
- (void)captureEnvelope:(SentryEnvelope *)envelope
709709
{
710-
SentryClient *client = _client;
710+
SentryClient *client = self.client;
711711
if (client == nil) {
712712
return;
713713
}
@@ -732,7 +732,7 @@ - (SentryEnvelope *)updateSessionState:(SentryEnvelope *)envelope
732732
[currentSession
733733
endSessionCrashedWithTimestamp:[SentryDependencyContainer.sharedInstance
734734
.dateProvider date]];
735-
if (_client.options.diagnosticLevel == kSentryLevelDebug) {
735+
if (self.client.options.diagnosticLevel == kSentryLevelDebug) {
736736
SENTRY_LOG_DEBUG(@"Ending session with status: %@",
737737
[self createSessionDebugString:currentSession]);
738738
}
@@ -811,15 +811,15 @@ - (NSString *)createSessionDebugString:(SentrySession *)session
811811

812812
- (void)flush:(NSTimeInterval)timeout
813813
{
814-
SentryClient *client = _client;
814+
SentryClient *client = self.client;
815815
if (client != nil) {
816816
[client flush:timeout];
817817
}
818818
}
819819

820820
- (void)close
821821
{
822-
[_client close];
822+
[self.client close];
823823
SENTRY_LOG_DEBUG(@"Closed the Hub.");
824824
}
825825

Sources/Sentry/SentryViewHierarchyIntegration.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ - (BOOL)installWithOptions:(nonnull SentryOptions *)options
4444

4545
self.options = options;
4646

47-
SentryClient *client = [SentrySDK.currentHub getClient];
47+
SentryClient *client = [SentrySDK.currentHub client];
4848
[client addAttachmentProcessor:self];
4949

5050
sentrycrash_setSaveViewHierarchy(&saveViewHierarchy);
@@ -63,7 +63,7 @@ - (void)uninstall
6363
{
6464
sentrycrash_setSaveViewHierarchy(NULL);
6565

66-
SentryClient *client = [SentrySDK.currentHub getClient];
66+
SentryClient *client = [SentrySDK.currentHub client];
6767
[client removeAttachmentProcessor:self];
6868
}
6969

0 commit comments

Comments
 (0)