Skip to content

Commit 92ad3c0

Browse files
authored
Fix warnings from new NIO (#54)
Motivation: The latest NIO release deprecated some APIs. Modifications: - Use non-deprecated APIs Result: No warnings
1 parent 61ae0ba commit 92ad3c0

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let dependencies: [Package.Dependency] = [
3939
),
4040
.package(
4141
url: "https://github.com/apple/swift-nio.git",
42-
from: "2.75.0"
42+
from: "2.78.0"
4343
),
4444
.package(
4545
url: "https://github.com/apple/swift-nio-http2.git",

Sources/GRPCNIOTransportCore/Internal/Base64.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@
7171
*/
7272

7373
// swift-format-ignore: DontRepeatTypeInStaticProperties
74-
enum Base64 {
75-
struct DecodingOptions: OptionSet {
76-
internal let rawValue: UInt
77-
internal init(rawValue: UInt) { self.rawValue = rawValue }
74+
package enum Base64 {
75+
package struct DecodingOptions: OptionSet {
76+
package let rawValue: UInt
77+
package init(rawValue: UInt) { self.rawValue = rawValue }
7878

79-
internal static let base64UrlAlphabet = DecodingOptions(rawValue: UInt(1 << 0))
80-
internal static let omitPaddingCharacter = DecodingOptions(rawValue: UInt(1 << 1))
79+
package static let base64UrlAlphabet = DecodingOptions(rawValue: UInt(1 << 0))
80+
package static let omitPaddingCharacter = DecodingOptions(rawValue: UInt(1 << 1))
8181
}
8282

8383
enum DecodingError: Error, Equatable {
@@ -87,7 +87,9 @@ enum Base64 {
8787
case unexpectedEnd
8888
}
8989

90-
static func encode<Buffer: Collection>(bytes: Buffer) -> String where Buffer.Element == UInt8 {
90+
package static func encode<Buffer: Collection>(
91+
bytes: Buffer
92+
) -> String where Buffer.Element == UInt8 {
9193
guard !bytes.isEmpty else {
9294
return ""
9395
}
@@ -122,7 +124,7 @@ enum Base64 {
122124
}
123125
}
124126

125-
static func decode(
127+
package static func decode(
126128
string encoded: String,
127129
options: DecodingOptions = []
128130
) throws -> [UInt8] {

Tests/GRPCNIOTransportCoreTests/GRPCStreamStateMachineTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ final class GRPCStreamClientStateMachineTests: XCTestCase {
438438
GRPCHTTP2Keys.contentType.rawValue: ContentType.grpc.canonicalValue,
439439
GRPCHTTP2Keys.encoding.rawValue: "deflate",
440440
"custom": "123",
441-
"custom-bin": String(base64Encoding: [42, 43, 44]),
441+
"custom-bin": Base64.encode(bytes: [42, 43, 44]),
442442
],
443443
endStream: false
444444
)
@@ -466,7 +466,7 @@ final class GRPCStreamClientStateMachineTests: XCTestCase {
466466
GRPCHTTP2Keys.contentType.rawValue: ContentType.grpc.canonicalValue,
467467
GRPCHTTP2Keys.encoding.rawValue: "deflate",
468468
"custom": "123",
469-
"custom-bin": String(base64Encoding: [42, 43, 44]),
469+
"custom-bin": Base64.encode(bytes: [42, 43, 44]),
470470
],
471471
endStream: false
472472
)
@@ -493,7 +493,7 @@ final class GRPCStreamClientStateMachineTests: XCTestCase {
493493
GRPCHTTP2Keys.contentType.rawValue: ContentType.grpc.canonicalValue,
494494
GRPCHTTP2Keys.encoding.rawValue: "deflate",
495495
"custom": "123",
496-
"custom-bin": String(base64Encoding: [42, 43, 44]),
496+
"custom-bin": Base64.encode(bytes: [42, 43, 44]),
497497
],
498498
endStream: false
499499
)

Tests/GRPCNIOTransportCoreTests/Server/Connection/ServerConnectionManagementHandlerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ struct ServerConnectionManagementHandlerTests {
167167
// Write a frame into the channel _without_ calling channel read complete. This will cancel
168168
// the keep alive timer.
169169
let settings = HTTP2Frame(streamID: .rootStream, payload: .settings(.settings([])))
170-
connection.channel.pipeline.fireChannelRead(NIOAny(settings))
170+
connection.channel.pipeline.fireChannelRead(settings)
171171

172172
// Run out the keep alive timer, it shouldn't fire.
173173
connection.advanceTime(by: .minutes(5))

Tests/GRPCNIOTransportCoreTests/Server/GRPCServerStreamHandlerTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ struct ServerStreamHandlerTests {
10711071
#expect(!handle.isCancelled)
10721072

10731073
let rstStream: HTTP2Frame.FramePayload = .rstStream(.cancel)
1074-
channel.pipeline.fireChannelRead(NIOAny(rstStream))
1074+
channel.pipeline.fireChannelRead(rstStream)
10751075

10761076
#expect(handle.isCancelled)
10771077
}
@@ -1091,7 +1091,7 @@ struct ServerStreamHandlerTests {
10911091

10921092
// FrameStats aren't affected by pings received
10931093
channel.pipeline.fireChannelRead(
1094-
NIOAny(HTTP2Frame.FramePayload.ping(.init(withInteger: 42), ack: false))
1094+
HTTP2Frame.FramePayload.ping(.init(withInteger: 42), ack: false)
10951095
)
10961096
#expect(!handlers.connectionHandler.frameStats.didWriteHeadersOrData)
10971097

0 commit comments

Comments
 (0)