You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Michael Hausegger (JIRA)" <ji...@apache.org> on 2017/06/16 19:06:00 UTC
[jira] [Resolved] (COMPRESS-412) NullPointerException defect in
ChecksumCalculatingInputStream#getValue()
[ https://issues.apache.org/jira/browse/COMPRESS-412?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
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.
{code:java}
public ChecksumCalculatingInputStream(final Checksum checksum, final InputStream in) {
//New
if ( checksum == null ){
throw new NullPointerException("Parameter checksum must not be null");
}
//New
if ( in == null ){
throw new NullPointerException("Parameter in must not be null");
}
this.checksum = checksum;
this.in = in;
}
{code}
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.
Thanks.
> NullPointerException defect in ChecksumCalculatingInputStream#getValue()
> ------------------------------------------------------------------------
>
> Key: COMPRESS-412
> URL: https://issues.apache.org/jira/browse/COMPRESS-412
> Project: Commons Compress
> Issue Type: Bug
> Reporter: Michael Hausegger
> Priority: Minor
>
> NullPointerException defect in ChecksumCalculatingInputStream#getValue() detected as stated in pull request 33: https://github.com/apache/commons-compress/pull/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
(v6.4.14#64029)