Skip to content

Commit

Permalink
Fix build warning
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmk committed Jan 29, 2024
1 parent 9c2d16f commit c519d86
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Sources/BenchmarkPubSub/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ try await withThrowingTaskGroup(of: Void.self) { group in
for await msg in sub {
let payload = msg.payload!
if String(data: payload, encoding: .utf8) != "\(i)" {
print("invalid payload; expected: \(i); got: \(String(data: payload, encoding: .utf8))")
let emptyString = ""
print("invalid payload; expected: \(i); got: \(String(data: payload, encoding: .utf8) ?? emptyString)")
}
guard let headers = msg.headers else {
print("empty headers!")
Expand All @@ -38,6 +39,7 @@ try await withThrowingTaskGroup(of: Void.self) { group in
if i%1000 == 0 {
print("received \(i) msgs")
}
i += 1
}
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/BenchmarkSub/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ for i in 1...numMsgs {
continue
}
if String(data: payload, encoding: .utf8) != "\(i)" {
print("invalid payload; expected: \(i); got: \(String(data: payload, encoding: .utf8))")
let emptyString = ""
print("invalid payload; expected: \(i); got: \(String(data: payload, encoding: .utf8) ?? emptyString)")
}
guard let headers = msg?.headers else {
guard msg?.headers != nil else {
print("empty headers!")
continue
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/NatsSwift/Extensions/Data+Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ extension Data {
if let headersString = String(data: headersData, encoding: .utf8) {
let headersArray = headersString.split(separator: "\r\n")
// TODO: unused now, but probably we should validate?
let versionLine = headersArray[0]
// let versionLine = headersArray[0]

for header in headersArray.dropFirst() {
let headerParts = header.split(separator: ":")
Expand Down
2 changes: 1 addition & 1 deletion Sources/NatsSwift/NatsConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class ConnectionHandler: ChannelInboundHandler {
}

func writeMessage(_ message: ByteBuffer) throws {
channel?.write(message)
_ = channel?.write(message)
if channel?.isWritable ?? true {
channel?.flush()
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/NatsSwiftTests/Integration/ConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CoreNatsTests: XCTestCase {
expectation.fulfill()
}
}
wait(for: [expectation], timeout: 5.0)
await fulfillment(of: [expectation], timeout: 5.0)
await sub.complete()
}

Expand All @@ -67,7 +67,7 @@ class CoreNatsTests: XCTestCase {
expectation.fulfill()
}
}
wait(for: [expectation], timeout: 5.0)
await fulfillment(of: [expectation], timeout: 5.0)
await sub.complete()
}

Expand Down Expand Up @@ -170,7 +170,7 @@ class CoreNatsTests: XCTestCase {
try await client.connect()
try client.publish("msg".data(using: .utf8)!, subject: "test")
try await client.flush()
try await client.subscribe(to: "test")
_ = try await client.subscribe(to: "test")
XCTAssertNotNil(client, "Client should not be nil")


Expand Down Expand Up @@ -207,7 +207,7 @@ class CoreNatsTests: XCTestCase {
try await client.connect()
try client.publish("msg".data(using: .utf8)!, subject: "test")
try await client.flush()
try await client.subscribe(to: "test")
_ = try await client.subscribe(to: "test")
XCTAssertNotNil(client, "Client should not be nil")


Expand Down

0 comments on commit c519d86

Please sign in to comment.