Skip to content

Commit 9bde7d3

Browse files
Hongyan JiangGitHub Enterprise
authored andcommitted
Fix crash caused by appendMetaData()
1 parent e83dee4 commit 9bde7d3

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 1.6.1
4+
- Fix crash caused by appendMetaData() inside InstanaProperties class
5+
36
## 1.6.0
47
- Refactor code and add more unit test cases
58

InstanaAgent.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = "InstanaAgent"
19-
s.version = "1.6.0"
19+
s.version = "1.6.1"
2020
s.summary = "Instana iOS agent."
2121

2222
# This description is used to generate tags and improve search results.

Sources/InstanaAgent/Beacons/CoreBeacon/CoreBeaconFactory.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ extension CoreBeacon {
5151
ui = properties.user?.id
5252
un = properties.user?.name
5353
ue = properties.user?.email
54-
m = !properties.metaData.isEmpty ? properties.metaData : nil
54+
let localMeta = properties.getMetaData()
55+
m = !localMeta.isEmpty ? localMeta : nil
5556
}
5657

5758
mutating func append(_ beacon: HTTPBeacon) {

Sources/InstanaAgent/Configuration/InstanaProperties.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class InstanaProperties {
4141
}
4242

4343
var user: User?
44-
private(set) var metaData = MetaData()
44+
private var metaData = MetaData()
45+
private let queueMetaData = DispatchQueue(label: "com.instana.ios.agent.metadata", attributes: .concurrent)
4546

4647
static let viewMaxLength = 256
4748
var view: String? {
@@ -59,8 +60,19 @@ class InstanaProperties {
5960
func appendMetaData(_ key: String, _ value: String) {
6061
let key = MetaData.validate(key: key)
6162
let value = MetaData.validate(value: value)
62-
if metaData.count < MetaData.Max.numberOfMetaEntries {
63-
metaData[key] = value
63+
queueMetaData.async(flags: .barrier) { [weak self] in
64+
guard let self = self else {
65+
return
66+
}
67+
if self.metaData.count < MetaData.Max.numberOfMetaEntries {
68+
self.metaData[key] = value
69+
}
70+
}
71+
}
72+
73+
func getMetaData() -> MetaData {
74+
return queueMetaData.sync {
75+
self.metaData
6476
}
6577
}
6678

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
struct VersionConfig {
2-
static let agentVersion = "1.6.0"
2+
static let agentVersion = "1.6.1"
33
}

Tests/InstanaAgentTests/Configuration/InstanaSystemUtilsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class InstanaSystemUtilsTests: InstanaTestCase {
55

66
func test_AgentVersion() {
77
// Then
8-
AssertTrue(InstanaSystemUtils.agentVersion == "1.6.0")
8+
AssertTrue(InstanaSystemUtils.agentVersion == "1.6.1")
99
}
1010

1111
func test_systemVersion() {

0 commit comments

Comments
 (0)