fix: remove force-unwrap on session dictionary in DefaultNetworkService (#1787)

- Instead of using force-unwrap to append to a list-valued
  dictionary entry that should always exist, assign the value
  with a default fallback and append to the (non-optional)
  result.
This commit is contained in:
SEPURI-SAI-KRISHNA
2026-06-23 09:52:05 -07:00
committed by GitHub
parent 0e3651b4f1
commit 5e125d8e2a
@@ -95,13 +95,13 @@ public actor DefaultNetworkService: NetworkService {
}
macAddresses[index] = macAddress
if allocationsBySession[session] == nil {
allocationsBySession[session] = []
let isNewSession = allocationsBySession[session] == nil
allocationsBySession[session, default: []].append((hostname: hostname, index: index))
if isNewSession {
await session.onDisconnect { [weak self] in
await self?.releaseSession(session)
}
}
allocationsBySession[session]!.append((hostname: hostname, index: index))
return (attachment: attachment, additionalData: additionalData)
}