{
  "WorkItem": {
    "AffectedComponent": {
      "Name": "",
      "DisplayName": ""
    },
    "ClosedComment": "not a bug.   Application error.",
    "ClosedDate": "2009-10-14T21:49:51.563-07:00",
    "CommentCount": 0,
    "Custom": null,
    "Description": "We've run into an issue where a file with the right size causes an ArgumentException with the latest code.  We previously were getting the exception reported in work item 8679 however in our case the size is > 8 bytes, not less.  We've re-run the test with the latest build (1.9.0.20) and now get a different error - an ArgumentException from Array.Copy on line 248 when it tries to write 37 bytes into an 8 byte array:\n// workitem 8679\n                        if (_z.AvailableBytesIn != 8)\n                        {\n                            // Make sure we have read to the end of the stream\n                            Array.Copy(_z.InputBuffer, _z.NextIn, trailer, 0, _z.AvailableBytesIn); // <--- exception thrown here\n                            int bytesNeeded = 8 - _z.AvailableBytesIn;\n                            int bytesRead = _stream.Read(trailer,\n                                                         _z.AvailableBytesIn,\n                                                         bytesNeeded);\n                            if (bytesNeeded != bytesRead)\n                            {\n                                throw new ZlibException(String.Format(\"Protocol error. AvailableBytesIn={0}, expected 8\",\n                                                                      _z.AvailableBytesIn + bytesRead));\n                            }\n                        }\n                        else\n                        {\n                            Array.Copy(_z.InputBuffer, _z.NextIn, trailer, 0, trailer.Length);\n                        }\n \nIt appears that the file is completely written, and slightly changing the file size causes the error to go away (although we changed the contents to do that, so...)  \n \nHere's how we're expanding it:\n                    //assume it's a compressed stream and put the GZip decompressor in line with it\n                    using (GZipStream decompressionStream = new GZipStream(stream, CompressionMode.Decompress, true))\n                    {\n                        using (FileStream databaseFileStream = new FileStream(databaseFileNamePath, FileMode.Create, FileAccess.Write, FileShare.None, 1024))\n                        {\n                            //pump everything through the stream into the file.\n                            byte[] bytes = new byte[ZlibConstants.WorkingBufferSizeDefault];\n                            int bytesRead;\n                            //Decompress works only through read so we HAVE to read to pull it from the original file.\n                            while ((bytesRead = decompressionStream.Read(bytes, 0, bytes.Length)) != 0)\n                            {\n                                databaseFileStream.Write(bytes, 0, bytesRead);\n                            }\n                            decompressionStream.Flush();\n                            databaseFileStream.Flush();\n                        }\n                    }\n \nThe stream is stored in a file, attached.  Here's how we generate it:\n            using (FileStream tempFileStream = new FileStream(destinationFileNamePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None))\n            {\n                using (GZipStream compressedStream = new GZipStream(tempFileStream, CompressionMode.Compress, true))\n                {\n                    using (FileStream sourceStream = new FileStream(sourceFileNamePath, FileMode.Open, FileAccess.Read, FileShare.Read ))\n                    {\n                        //now write it out to a temporary location, but zipped...\n                        //pump everything through the stream into the file.\n                        byte[] bytes = new byte[4096];\n                        int bytesRead;\n                        while ((bytesRead = sourceStream.Read(bytes, 0, bytes.Length)) != 0)\n                        {\n                            compressedStream.Write(bytes, 0, bytesRead);\n                        }\n                        compressedStream.Flush();\n                    }\n                }\n                tempFileStream.Flush();\n \n                if (tempFileStream.Length == 0)\n                    Debugger.Break();\n            }",
    "LastUpdatedDate": "2013-05-16T05:32:02.927-07:00",
    "PlannedForRelease": "",
    "ReleaseVisibleToPublic": false,
    "Priority": {
      "Name": "Low",
      "Severity": 50,
      "Id": 1
    },
    "ProjectName": "DotNetZip",
    "ReportedDate": "2009-10-14T21:18:45.647-07:00",
    "Status": {
      "Name": "Closed",
      "Id": 4
    },
    "ReasonClosed": {
      "Name": "Unassigned"
    },
    "Summary": "Decompressing GZip stream can throw ArgumentException on finish for certain sizes",
    "Type": {
      "Name": "Issue",
      "Id": 3
    },
    "VoteCount": 1,
    "Id": 8986
  },
  "FileAttachments": [
    {
      "FileId": 2369,
      "FileName": "Gibraltar_Index_Ref.vdb3.gz",
      "DownloadUrl": ".\\2369"
    }
  ],
  "Comments": [
    {
      "Message": "This is our defect - our file compression routine shown above didn't truncate the destination file before it overwrote it so if a file recompressed smaller than its original it would leave the extra around, which is what was causing an error when expanding the stream.  If I knew how to reject a defect I'd mark this rejected.  My apologies.",
      "PostedDate": "2009-10-14T21:29:04.29-07:00",
      "Id": -2147483648
    },
    {
      "Message": "no problem, I'll close it. \r\nThanks for being so clear about it. ",
      "PostedDate": "2009-10-14T21:49:29.303-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2009-10-14T21:49:51.563-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-02-21T18:43:54.723-08:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-05-16T05:32:02.927-07:00",
      "Id": -2147483648
    }
  ]
}