GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Misleading comment in ChannelInitializer.initChannel(...) · Issue #16846 · netty/netty

Misleading comment in ChannelInitializer.initChannel(...) #16846

New issue
Copy link
New issue
Copy link
Closed
#16853
Closed
Misleading comment in ChannelInitializer.initChannel(...)#16846
#16853
Copy link

Description

@doxlik
doxlik
opened on May 22, 2026
Issue body actions

Hi, and thank you for Netty.

While reading current 4.2 ChannelInitializer, I noticed what looks like a small misleading comment.

In initChannel(ChannelHandlerContext ctx), the catch block says:

// Explicitly call exceptionCaught(...) as we removed the handler before calling initChannel(...).
// We do so to prevent multiple calls to initChannel(...).
exceptionCaught(ctx, cause);

But in the current code, the initializer is removed later in the finally block:

finally {
    if (!ctx.isRemoved()) {
        ctx.pipeline().remove(this);
    }
}

So it looks like the handler is not removed before calling initChannel((C) ctx.channel()).

My understanding is that re-entrance is guarded by initMap.add(ctx), and the initializer is removed after the init attempt.

Would it make sense to update this comment to avoid confusion?

Code link:
https://github.com/netty/netty/blob/4.2/transport/src/main/java/io/netty/channel/ChannelInitializer.java#L783-L803

Thanks.

Activity

  1. daguimu commented on May 24, 2026

    @daguimu
    daguimu
    on May 24, 2026
    Contributor
    More actions

    Good catch. I'd like to take this — small docs-only PR targeting 4.1 so auto-port carries it to 4.2/5.0 (the same wording exists on all three branches). The rewrite I have in mind names the actual mechanisms: initMap.add(ctx) for re-entrance and the finally block for handler removal.

  2. normanmaurer
    added 2 commits that reference this issue on May 28, 2026

    ChannelInitializer: correct misleading comment on exceptionCaught rou…

    This issue will close once commit 22d1be6 is merged into the '4.2' branch.
    22d1be6

    Auto-port 5.0: ChannelInitializer: correct misleading comment on exce…

    This issue will close once commit c8d08c0 is merged into the '4.2' branch.
    c8d08c0
  3. normanmaurer
    closed this as completedin #16853on May 28, 2026
  4. normanmaurer
    added a commit that references this issue on May 28, 2026

    Auto-port 4.2: ChannelInitializer: correct misleading comment on exce…

    This issue will close once commit 637f8d3 is merged into the '4.2' branch.
    637f8d3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.