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

NullPointerException when creation fields/entries from scratch

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8.1
    • Component/s: Archivers
    • Labels:
      None
    • Environment:

      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

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

              Dates

              • Created:
                Updated:
                Resolved: