Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.app

Instruments/ActorInstruments/ActorInstruments.xcodeproj/xcuserdata
Instruments/ActorInstruments/build/
Instruments/ActorInstruments/ActorInstruments.xcodeproj/project.xcworkspace/xcuserdata

Samples/swift-distributed-actors-samples.xcodeproj
Expand Down
14 changes: 7 additions & 7 deletions Sources/DistributedActors/GenActors/Actorable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ public enum Reply<Value> {
extension Reply {
public static func from<Answer>(askResponse: AskResponse<Answer>) -> Reply<Value> {
switch askResponse {
case .completed(let result as Result<Value, Error>):
switch result {
case .success(let value):
return .completed(.success(value))
case .failure(let error):
return .completed(.failure(ErrorEnvelope(error)))
}
case .completed(.success(let value as Value)):
return .completed(.success(value))
case .completed(.success(let value)):
return .completed(.failure(ErrorEnvelope(description: "Received unexpected reply value \(reflecting: type(of: value as Any)), expected: \(Value.self), message: \(value)")))

case .completed(.failure(let error)):
return .completed(.failure(ErrorEnvelope(error)))

case .nioFuture(let nioFuture as EventLoopFuture<Value>):
return .nioFuture(nioFuture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ final class ActorableOwnedMembershipTests: ClusteredActorSystemsXCTestCase {
}
}
}

func test_notCrashHard_whenCall_onShutDownSystem() throws {
let first = self.setUpNode("first")

let p = self.testKit(first).spawnTestProbe(expecting: Reception.Listing<Actor<OwnerOfThings>>.self)
let owner: Actor<OwnerOfThings> = try first.spawn("owner") {
OwnerOfThings(context: $0, probe: p.ref)
}

try first.shutdown().wait()
let x = owner.readLastObservedValue()
do {
let reply = try x.wait()
XCTFail("Expected call to throw, but got: \(optional: reply)")
} catch {
"\(error)".shouldContain("DistributedActors.AskError")
}
}
}

struct TestMembershipOwner: Actorable {
Expand Down
4 changes: 2 additions & 2 deletions Tests/DistributedActorsTests/SerializationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class SerializationTests: ActorSystemXCTestCase {
#else
if #available(macOS 10.16, *) {
() // ok, it's available on these platforms
} else if ok {
} else {
ok = false
}
#endif
Expand Down Expand Up @@ -466,7 +466,7 @@ class SerializationTests: ActorSystemXCTestCase {
#else
if #available(macOS 10.16, *) {
() // ok, it's available on these platforms
} else if ok {
} else {
ok = false
}
#endif
Expand Down