Skip to content

第二部分编解码器第11.4.1章节中代码清单 11-9中的代码有误,可能造成误导 #103

@SuMiaoALi

Description

@SuMiaoALi

ByteBuf.slice(int index, int length)方法是从fromInex开始切割长度length的字节,而书中代码错误,当成了切割到endIndex位置,导致运行时出现IndexOutOfBoundsException异常,对初学者可能产生误导。

image

书中代码测试结果:

image

正确示例:

image

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