You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stefan Bodewig (JIRA)" <ji...@apache.org> on 2014/04/18 16:14:18 UTC

[jira] [Resolved] (COMPRESS-273) NullPointerException when creation fields/entries from scratch

     [ https://issues.apache.org/jira/browse/COMPRESS-273?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Bodewig resolved COMPRESS-273.
-------------------------------------

    Resolution: Fixed

added a few null guards in svn revision 1588476

> NullPointerException when creation fields/entries from scratch
> --------------------------------------------------------------
>
>                 Key: COMPRESS-273
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-273
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Archivers
>    Affects Versions: 1.8
>         Environment: Mac OS 10.9, Java 6 and 7
>            Reporter: Cyrille Artho
>             Fix For: 1.9
>
>         Attachments: RandoopTest.java
>
>
> The API has public default constructors for many data types. However, when these 0-argument constructors are used, certain internal references are null, resulting in a NullPointerException soon after.
> This also applies to some 1-argument constructors where two references should be set before get... is used later.
> Either (1) these constructors should be non-public, (2) there should be documentation that certain fields need to be set later for an instance to be usable. In the latter case, there must be public set methods for the missing data.
> The attachment contains a number of similar test cases that show the same issue in a couple of classes.
> An example:
>     org.apache.commons.compress.archivers.zip.UnicodeCommentExtraField var0 = new org.apache.commons.compress.archivers.zip.UnicodeCommentExtraField();
>     org.apache.commons.compress.archivers.zip.ZipShort var1 = var0.getLocalFileDataLength();



--
This message was sent by Atlassian JIRA
(v6.2#6252)