mirror of
https://github.com/apple/container.git
synced 2026-09-22 15:45:38 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user