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 — NullPointerException while reading a compressed file · Issue #174 · lz4/lz4-java

This repository was archived by the owner on Dec 2, 2025. It is now read-only.
This repository was archived by the owner on Dec 2, 2025. It is now read-only.

NullPointerException while reading a compressed file #174

Copy link
Copy link
Closed
Closed
NullPointerException while reading a compressed file#174
Copy link

Description

@MarcoBerlot
MarcoBerlot
opened on Dec 15, 2020
Issue body actions

Describe the bug
Null pointer exception being thrown while attempting to read lz4 file.

java.lang.NullPointerException
at net.jpountz.lz4.LZ4FrameInputStream.read(LZ4FrameInputStream.java:295)
at java.base/java.io.FilterInputStream.read(Unknown Source)

Expected behavior
The file should be properly uncompressed and read.

To Reproduce
Unfortunately I can't provide steps to reproduce since this has happened in our production environment. Here's the function that is reading the lz4 files

private byte[] readCompressedFile(File file) throws IOException {
        LZ4FrameInputStream gis = new LZ4FrameInputStream(new FileInputStream(file));
        ByteArrayOutputStream fos = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int len;
        while ((len = gis.read(buffer)) != -1) {
            fos.write(buffer, 0, len);
        }
        fos.close();
        gis.close();
        return fos.toByteArray();
    }

System (please complete the following information):

  • OS: CentOS Linux release 7.8.2003 (Core)
  • Compiler: OpenJ9
  • Build System [e.g. Makefile]
  • Other hardware specs [e.g Core 2 duo...]

Activity

  1. odaira commented on Dec 16, 2020

    @odaira
    odaira
    on Dec 16, 2020
    Member
    More actions

    Thanks for reporting this. What version of lz4-java are you using?

  2. MarcoBerlot commented on Dec 16, 2020

    @MarcoBerlot
    MarcoBerlot
    on Dec 16, 2020
    Author
    More actions
    Java version: 10.0.1 (build 10.0.1+10) x 86_64
    openjdk 11.0.9 2020-10-20 LTS
    OpenJDK Runtime Environment 18.9 (build 11.0.9+11-LTS)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.9+11-LTS, mixed mode, sharing)
    

    Thanks @odaira

  3. MarcoBerlot
    changed the title [-]NullPointerException while reading the a compressed file[/-] [+]NullPointerException while reading a compressed file[/+] on Dec 16, 2020
  4. MarcoBerlot commented on Dec 16, 2020

    @MarcoBerlot
    MarcoBerlot
    on Dec 16, 2020
    Author
    More actions

    One way that I was able to reproduce this is by passing an empty file. In this case nextFrameInfo(); will return early and ByteBuffer buffer won't be initialized and when it tries to read the file it will encounter a NPE.
    I believe a more explicit exception might help in this case, or make sure that the buffer gets initialized also in the case of an empty file.

  5. odaira commented on Dec 17, 2020

    @odaira
    odaira
    on Dec 17, 2020
    Member
    More actions

    @MarcoBerlot These are the versions of your Java runtime, but I would like to know the version of lz4-java you are using.

    Java version: 10.0.1 (build 10.0.1+10) x 86_64
    openjdk 11.0.9 2020-10-20 LTS
    OpenJDK Runtime Environment 18.9 (build 11.0.9+11-LTS)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.9+11-LTS, mixed mode, sharing)

    Doesn't your application include a jar file named lz4-java-x.y.z.jar, like lz4-java-1.7.1.jar? Then x.y.z is the version of lz4-java.

  6. MarcoBerlot commented on Dec 17, 2020

    @MarcoBerlot
    MarcoBerlot
    on Dec 17, 2020
    Author
    More actions

    @odaira sorry, I did not read it correctly. I'm using version 1.4

  7. odaira commented on Jun 5, 2021

    @odaira
    odaira
    on Jun 5, 2021
    Member
    More actions

    Fixed by 5e23573 and fa30b17. Thank you for your help!

  8. odaira
    closed this as completedon Jun 5, 2021
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.