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 — ByteBufInputStream#readByte(); should use checkAvailable(); method · Issue #15305 · netty/netty

ByteBufInputStream#readByte(); should use checkAvailable(); method #15305

New issue
Copy link
New issue
Copy link
Closed
#15314
Closed
ByteBufInputStream#readByte(); should use checkAvailable(); method#15305
#15314
Copy link
Milestone
4.2.3.Final

Description

@d-william
d-william
opened on Jun 2, 2025
Issue body actions

Is there any particular reason not to use the checkAvailable(); method in the #readByte(); method ?
While in all other #read[...](); method (of DataInput interface), the checkAvailable(); method is used.

It makes inconsistenty in error messages :

ByteBufInputStream in = new ByteBufInputStream(Unpooled.buffer());

try {
    in.readByte();
}
catch (IOException e) {
    System.out.println("Message: " + e.getMessage()); // null
}

try {
    in.readShort();
}
catch (IOException e) {
    System.out.println("Message: " + e.getMessage()); // "fieldSize is too long! Length is 2, but maximum is 0"
}

Can the metod look like :

@Override
public byte readByte() throws IOException {
    checkAvailable(1);
    return buffer.readByte();
}

or :

@Override
public byte readByte() throws IOException {
    int available = available();
    if (available == 0) {
        throw new EOFException("fieldSize is too long! Length is 1, but maximum is 0");
    }
    return buffer.readByte();
}

Activity

  1. normanmaurer commented on Jun 3, 2025

    @normanmaurer
    normanmaurer
    on Jun 3, 2025
    Member
    More actions

    @d-william feel free to open a PR. I think we can use the checkAvailable(1) variant

    Reacted by William
  2. d-william
    added a commit that references this issue on Jun 4, 2025

    Use checkAvailable(); in #readByte(); method (netty#15305)

    2e93e31
  3. normanmaurer
    closed this as completedin #15314on Jun 5, 2025
  4. normanmaurer
    added 2 commits that reference this issue on Jun 5, 2025

    Use checkAvailable(); in #readByte(); method (#15305) (#15314)

    b907d26

    Use checkAvailable(); in #readByte(); method (#15305) (#15314)

    51d3555
  5. normanmaurer
    added this to the 4.2.3.Final milestone on Jun 5, 2025
  6. normanmaurer
    added a commit that references this issue on Jun 6, 2025

    Use checkAvailable(); in #readByte(); method (#15305) (#15314) (#15319)

    d7da6df
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

      • 4.2.3.Final

      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.