Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dissallow access and removal of Head and Tail ChannelHandlers #225

Merged
merged 1 commit into from
Mar 23, 2018

Conversation

normanmaurer
Copy link
Member

Motivation:

The Head and Tail ChannelHandlers should not be accessible as these are implementation details of the ChannelPipeline and removal of these will even make the whole ChannelPipeline not work anymore.

Modifications:

  • Make it impossible to access / removal the Head and Tail ChannelHandlers
  • Exclude the Head and Tail ChannelHandler from the debug String
  • Add unit tests.

Result:

More robust ChannelPipeline.

Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one small note.

}

do {
_ = try channel.pipeline.context(name: "head").wait()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to look for these handlers by type, as we couldn't fix that by just removing their names.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added an extra assert for that

@normanmaurer
Copy link
Member Author

@Lukasa PTAL again

///
/// - parameters:
/// - body: The predicate to execute per `ChannelHandlerContext` in the `ChannelPipeline`.
/// -returns: The `ChannelHandlerContext` that matches or `nil` if non did.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should note that this returns the first ChannelHandlerContext that matches, not the only one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -446,9 +446,16 @@ public final class ChannelPipeline: ChannelInvoker {
return promise.futureResult
}

/// Returns a `ChannelHandlerContext` which matches.
///
/// This skips head and tail (as these are internal and should not be accessible by the user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unbalanced parenthesis.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Motivation:

The Head and Tail ChannelHandlers should not be accessible as these are implementation details of the ChannelPipeline and removal of these will even make the whole ChannelPipeline not work anymore.

Modifications:

- Make it impossible to access / removal the Head and Tail ChannelHandlers
- Exclude the Head and Tail ChannelHandler from the debug String
- Add unit tests.

Result:

More robust ChannelPipeline.
@normanmaurer normanmaurer self-assigned this Mar 23, 2018
@normanmaurer normanmaurer added kind/bug Feature doesn't work as expected. 🔨 semver/patch No public API change. labels Mar 23, 2018
@normanmaurer normanmaurer added this to the 1.3.0 milestone Mar 23, 2018
@normanmaurer normanmaurer merged commit eb60e89 into apple:master Mar 23, 2018
@normanmaurer normanmaurer deleted the pipeline_head_tail branch March 23, 2018 14:02
@normanmaurer
Copy link
Member Author

@Lukasa thanks for the review...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Feature doesn't work as expected. 🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants