Skip to content

Commit

Permalink
undo tiny public API breakage
Browse files Browse the repository at this point in the history
Motivation:

In #957 we accidentally broke the API just a little bit. We turned the
`ByteToMessageHandler.init` from

    public init(_ decoder: Decoder)

into

    public init(_ decoder: Decoder, maximumBufferSize: Int? = nil)

This looks totally benign and in almost all cases because of the default
argument, you wouldn't notice the API breakage. However, it's possible
to write code that works in NIO 2.0.0 but breaks in NIO 2.1.0. For
example

    let g: (Dummy) -> ByteToMessageHandler<Dummy> = ByteToMessageHandler<Dummy>.init
    let h: (Dummy) -> ByteToMessageHandler<Dummy> = ByteToMessageHandler<Dummy>.init(_:)

Modifications:

According to SemVer, this releases a patch that unbreaks the public API.

Result:

No API breakages (checked with `swift-api-digester` which also found the
breakage in the first place).
  • Loading branch information
weissi committed May 17, 2019
1 parent 0e37ada commit b2be49a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/NIO/Codec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ public final class ByteToMessageHandler<Decoder: ByteToMessageDecoder> {
private var seenEOF: Bool = false
private var selfAsCanDequeueWrites: CanDequeueWrites? = nil

/// @see: ByteToMessageHandler.init(_:maximumBufferSize)
public convenience init(_ decoder: Decoder) {
self.init(decoder, maximumBufferSize: nil)
}

/// Initialize a `ByteToMessageHandler`.
///
/// - parameters:
Expand Down

0 comments on commit b2be49a

Please sign in to comment.