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/13 11:11:14 UTC

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

    [ https://issues.apache.org/jira/browse/COMPRESS-273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13967763#comment-13967763 ] 

Stefan Bodewig commented on COMPRESS-273:
-----------------------------------------

for the implementations of ZipExtraField the no-arg constructors are an implementation detail - they are supposed to be used together with the parseFrom* methods.

I'll look into improving the state verification for the classes you are hitting with your tests.  In all cases the API isn't used as it is supposed to be, so part of the fix will be adapting Javadocs.

> 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)