commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Hausegger (JIRA)" <>
Subject [jira] [Resolved] (COMPRESS-412) NullPointerException defect in ChecksumCalculatingInputStream#getValue()
Date Fri, 16 Jun 2017 19:06:00 GMT


Michael Hausegger resolved COMPRESS-412.
    Resolution: Done

Issue is fixed.

What did I do?
Modified the constructor to assure the input parameters are not null.

    public ChecksumCalculatingInputStream(final Checksum checksum, final InputStream in) {
        if ( checksum == null ){
            throw new NullPointerException("Parameter checksum must not be null");
        if ( in == null ){
            throw new NullPointerException("Parameter in must not be null");

        this.checksum = checksum; = in;

Due to the fact that when the in parameter is null the same problem would happen the same
check as for the checksum parameter was built in.

A manual verification in conjunction with raising an explicit NullPointerExeception over verification
using an assert framework was chosen due to the fact that this - after code inspection - turned
out to obviously beeing the standard approach in the current project.

Hope this helps.

> NullPointerException defect in ChecksumCalculatingInputStream#getValue()
> ------------------------------------------------------------------------
>                 Key: COMPRESS-412
>                 URL:
>             Project: Commons Compress
>          Issue Type: Bug
>            Reporter: Michael Hausegger
>            Priority: Minor
> NullPointerException defect in ChecksumCalculatingInputStream#getValue() detected as
stated in pull request 33:
> Furthermore the following test describes the problem:
> {code:java}
>     @Test(expected = NullPointerException.class) //I assume this behaviour to be a bug
or at least a defect.
>     public void testGetValueThrowsNullPointerException() {
>         ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(null,null);
>         checksumCalculatingInputStream.getValue();
>     }
> {code}

This message was sent by Atlassian JIRA

View raw message