Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-273

NullPointerException when creation fields/entries from scratch

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.8
    • 1.8.1
    • Archivers
    • None
    • Mac OS 10.9, Java 6 and 7

    Description

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

      Attachments

        1. RandoopTest.java
          3 kB
          Cyrille Artho

        Activity

          People

            Unassigned Unassigned
            Telcontar Cyrille Artho
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: